Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Modify /proc/<pid>/cmdline only #124

Open
dlucredativ opened this issue Nov 25, 2022 · 2 comments
Open

Feature: Modify /proc/<pid>/cmdline only #124

dlucredativ opened this issue Nov 25, 2022 · 2 comments

Comments

@dlucredativ
Copy link

setproctitle.setproctitle modifies /proc/<pid>/cmdline as well as /proc/<pid>/status. I would like to modify what is seen via ps but retain what e.g. systemctl status shows.

This is what one gets without setproctitle:

user@demo:~$ cat /usr/local/bin/proctitle-demo 
#!/usr/bin/python3

#import setproctitle
import sys

from time import sleep

#setproctitle.setproctitle(' '.join(sys.argv))

while True:
    sleep(1)
user@demo:~$ systemctl status proctitle-demo
● proctitle-demo.service - proctitle-demo
   Loaded: loaded (/etc/systemd/system/proctitle-demo.service; static; vendor preset: enabled)
   Active: active (running) since Fri 2022-11-25 15:30:38 CET; 1min 12s ago
 Main PID: 20802 (proctitle-demo)
    Tasks: 1 (limit: 1149)
   Memory: 2.8M
   CGroup: /system.slice/proctitle-demo.service
           └─20802 /usr/bin/python3 /usr/local/bin/proctitle-demo
user@demo:~$ ps aux | grep 20802 | grep -v grep
63158    20802  0.0  0.8  23040  8544 ?        Ss   15:30   0:00 /usr/bin/python3 /usr/local/bin/proctitle-demo

This is what one gets with setproctitle:

user@demo:~$ sudo vim /usr/local/bin/proctitle-demo
user@demo:~$ cat /usr/local/bin/proctitle-demo 
#!/usr/bin/python3

import setproctitle
import sys

from time import sleep

setproctitle.setproctitle(' '.join(sys.argv))

while True:
    sleep(1)
user@demo:~$ sudo systemctl restart proctitle-demo
user@demo:~$ systemctl status proctitle-demo
● proctitle-demo.service - proctitle-demo
   Loaded: loaded (/etc/systemd/system/proctitle-demo.service; static; vendor preset: enabled)
   Active: active (running) since Fri 2022-11-25 15:32:39 CET; 2s ago
 Main PID: 20879 (/usr/local/bin/)
    Tasks: 1 (limit: 1149)
   Memory: 2.8M
   CGroup: /system.slice/proctitle-demo.service
           └─20879 /usr/local/bin/proctitle-demo
user@demo:~$ ps aux | grep 20879 | grep -v grep
63158    20879  0.0  0.8  25104  8608 ?        Ss   15:32   0:00 /usr/local/bin/proctitle-demo
user@demo:~$ 

The ps output as well as the CGroup tree has been modified as desired, but the Main PID line is unaesthetic.

@dvarrazzo
Copy link
Owner

I don't personally see a reason to introduce this feature. Would you like to sponsor it, or to propose a merge request?

@dlucredativ
Copy link
Author

I might try a merge request some day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants