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

Donn Cave donn at u.washington.edu
Tue Feb 13 20:00:10 EST 2001


Quoth "Steven D. Majewski" <sdm7g at virginia.edu>:
| 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.

It looks to me like the only platforms that have setproctitle()
at this point are NetBSD, FreeBSD, OpenBSD and BSDI.  Most of the
rest of the UNIX world does have some way to overwrite the command
line as seen from "ps", but not all very pretty.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list