Author piro
Recipients amaury.forgeotdarc, asksol, elprans, exarkun, flub, giampaolo.rodola, iElectric, loewis, marcelo_fernandez, piro, serverhorror
Date 2009-12-06.19:11:10
SpamBayes Score 1.14253e-12
Marked as misclassified No
Message-id <1260126673.27.0.867693282427.issue5672@psf.upfronthosting.co.za>
In-reply-to
Content
> I'm taking a look at it, and it seems to use setproctitle() in BSD, 
and 
> writes over the argv array "in most Sys-V like systems"; this 
includes 
> Linux?

Yes: Linux uses what in the source is referred as the 
PS_USE_CLOBBER_ARGV strategy: it writes over the area pointed by argv 
and by environ (after checked they are contiguous and moved away). 
Sounds scary, but I've tested that environ keeps working fine (the 
environ can be modified and forked processes receive the correct 
environment).

> 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?

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``.

I don't know which method is better (well, I happen to prefer the 
extended visualization provided by the cmdline, which natively shows 
more detail than just the process name shown in ``status`` but this is 
probably subjective).

> Could this module be altered to use a prctl call in Linux (>2.6.9)?

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.

[2] http://code.google.com/p/py-setproctitle/source/browse/tools/
History
Date User Action Args
2009-12-06 19:11:14pirosetrecipients: + piro, loewis, exarkun, amaury.forgeotdarc, giampaolo.rodola, flub, serverhorror, iElectric, marcelo_fernandez, elprans, asksol
2009-12-06 19:11:13pirosetmessageid: <1260126673.27.0.867693282427.issue5672@psf.upfronthosting.co.za>
2009-12-06 19:11:11pirolinkissue5672 messages
2009-12-06 19:11:10pirocreate