setproctitle [was: How do I change a process name or even a thread name in python!]

Steven D. Majewski sdm7g at virginia.edu
Tue Feb 13 19:16:53 EST 2001


On Tue, 13 Feb 2001, Oleg Broytmann wrote:

> On 13 Feb 2001, Erno Kuusela wrote:
> > clearly, python needs setproctitle() in the posix module.
> 
>    For a long long while I longing to write one, but always short on time!
> 

Because of the posix_1str wrapper in posixmodule, it ought to be pretty
trivial ... something like:

- #ifdef HAVE_SETPROCTITLE
- 
- static char posix_setproctitle__doc__[] = 
- "setproctitle(path) -> None\n\
- Set the process title."; 
- 
- static PyObject *
- posix_setproctitle(PyObject *self, PyObject *args)
- {
-       return posix_1str(args, "s:setproctitle", setproctitle);
- }
- 
- #endif HAVE_SETPROCTITLE


I was about to try this, but I discovered that althought there's
a man page to setproctitle(3) in macosx/darwin, they inadvertently
left that function out of the public beta. ( Well -- more precisely,
I'm told the code is there, but it's not in the library. )  

The actual args to (C) setproctitle is a format string and optional
args, but it makes more sense to do any string formatting in Python,
and just pass that string. 

A nicer implementation would allow no arg to reset to the default
proctitle.

-- Steve Majewski






More information about the Python-list mailing list