Author marcelo_fernandez
Recipients amaury.forgeotdarc, asksol, elprans, exarkun, flub, giampaolo.rodola, iElectric, loewis, marcelo_fernandez, piro, serverhorror
Date 2009-12-06.20:10:29
SpamBayes Score 5.44009e-15
Marked as misclassified No
Message-id <>
In-reply-to <>
2009/12/6 Daniele Varrazzo <>:
>> My question is because I think there's a better and supported method
> for
>> Linux, that is, using prctl [1]. I read somewhere that changing argv
>> causes some inconsistencies between programs who read /sys files,
> /proc
>> files... or I don't remember what, but it is, in fact, not the
>> *recommended* way. Prctl is. :-)
> This is interesting: do you have any reference?

For example, take a look at the comments here:

It seems that some utilities and programs (killall,
gnome-system-monitor, and so on) looks for the process name in
/proc/PID/status, not in /proc/PID/cmdline, so it should be better (in
Linux), to modify both, /proc/PID/cmdline (changing argv) *and*
/proc/PID/status (calling prctl()).

I installed py-setproctitle, and can't kill it with killall once I set
the name to "hello", for example. :-(

[1]+  Detenido                python
marcelo@marcelo-laptop:~/src/py-setproctitle$ ps a
 1030 tty4     Ss+    0:00 /sbin/getty -8 38400 tty4
 1033 tty5     Ss+    0:00 /sbin/getty -8 38400 tty5
 1049 tty2     Ss+    0:00 /sbin/getty -8 38400 tty2
 1050 tty3     Ss+    0:00 /sbin/getty -8 38400 tty3
 1052 tty6     Ss+    0:00 /sbin/getty -8 38400 tty6
 1349 tty7     Ss+   17:14 /usr/bin/X :0 -br -verbose -auth
/var/run/gdm/auth-for-gdm-XhETSO/database -nolisten tcp vt7
 2225 tty1     Ss+    0:00 /sbin/getty -8 38400 tty1
10344 pts/0    Ss+    0:00 /bin/bash -l
11923 pts/1    Ss     0:00 bash
12068 pts/2    Ss+    0:00 bash
12485 pts/1    T      0:00 hello
12496 pts/1    R+     0:00 ps a
marcelo@marcelo-laptop:~/src/py-setproctitle$ killall hello
hello: proceso no encontrado

Another example: The gnome-system-monitor still lists the 'hello'
process (PID 12485) like 'python'. So we should try

> I've tested with the difference between clobbering argv and call
> prctl: two demo programs are in the tools directory of the module
> project [2].
> For what I observed, clobbering argv changes what shown in
> ``/proc/PID/cmdline``, whereas prctl changes what can be read in
> ``/proc/PID/status`` (and ``stat`` too). ``ps`` uses the former, but
> switches to the latter when calling ``ps a`` and ``ps f``. ``top``
> toggles between the two pressing ``c``.

Sorry, but here (Ubuntu 9.10) it works the other way around: "ps"
lists the /proc/PID/status -> name field and "ps a" lists the
/proc/PID/cmdline. But I got the explanation. :-)

> I think is probably better to have both strings updated: I'd prefer
> this behavior instead of the title being set in different places on
> different Linux versions.

IMHO, I'd prefer both things: to change the argv array *and* calling
prctl() if possible (Linux >2.6.9). If Linux is lower than 2.6.9,
fallback to change argv only.

Marcelo F. Fernández
Buenos Aires, Argentina
Licenciado en Sistemas - CCNA

Date User Action Args
2009-12-06 20:10:34marcelo_fernandezsetrecipients: + marcelo_fernandez, loewis, exarkun, amaury.forgeotdarc, giampaolo.rodola, flub, piro, serverhorror, iElectric, elprans, asksol
2009-12-06 20:10:30marcelo_fernandezlinkissue5672 messages
2009-12-06 20:10:29marcelo_fernandezcreate