setprocname

John Nagle nagle at animats.com
Mon Jun 14 16:00:49 EDT 2010


On 6/14/2010 12:31 PM, Thomas Jollans wrote:
> On 06/14/2010 08:41 PM, Tomasz Pajor wrote:
>> Hello,
>>
>> Why there is no setprocname function in standard library, or am I
>> missing something?
>
> why should there be one? what should it do?
>
> This sounds like you expect there to be a wrapper of a C system call or
> other libc function called "setprocname". There is no "setprocname"
> manual page installed on my system, which suggests to me that there is
> no such function, at least not in the GNU libc. I may be wrong.
>
> What makes you expect the existence of this function, and on which platform?

    This is useful if you're running some web app that has many
processes running, and you'd like some indication of who's doing
what for debugging and administration purposes.  Some daemons change 
their title as they run to indicate what they're doing.  Do a "ps ax"
on Linux, and you'll see some examples.

    (If the original poster simply wants to change the name in the
window of a GUI app, that's a function of the GUI.)

    BSD systems support "setproctitle", which changes the name of the
program visible in "ps", "top", etc.

    Linux doesn't have "setproctitle".  Linux 2.6.9 and later, though,
have a PR_SET_NAME function in "prtcl", to set the process name.

    There's a way to do this in Windows.  Look in Task Manager,
with a browser running, and the description for each Firefox
instance will show the page being displayed.

    Perl supports program name changing.  Storing into "$0"
does the appropriate platform-specific thing behind the
scenes.

    It's a reasonable capability to have in Python.  I have an
application which has a large number of copies of the same Python
program running on a server, and it would be useful to be able to
see, in "ps" and "top", which one was doing what.

					John Nagle



More information about the Python-list mailing list