This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
| Author | marcelo_fernandez |
|---|---|
| Recipients | amaury.forgeotdarc, giampaolo.rodola, loewis, marcelo_fernandez |
| Date | 2009年04月06日.17:08:08 |
| SpamBayes Score | 2.1926905e-14 |
| Marked as misclassified | No |
| Message-id | <1239037693.19.0.901372393233.issue5672@psf.upfronthosting.co.za> |
| In-reply-to |
| Content | |
|---|---|
This patch (to python 2.7 trunk) allows to call prctl() function from Linux kernel to change the process name. It adds two methods to the os module: os.getprocname() and os.setprocname(). Working example: marcelo@marcelo-laptop:~/src/pytrunk$ ./python Python 2.7a0 (trunk:71261M, Apr 5 2009, 16:32:55) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os [34831 refs] >>> os.getprocname() './python' [34833 refs] >>> os.getpid() 5601 [34833 refs] >>> os.setprocname('hello_process_name') [34833 refs] >>> os.getprocname() 'hello_process_name' [34833 refs] Before changing the process name: marcelo@marcelo-laptop:~/src/pytrunk$ ps -fax | grep 5601 Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html 5601 pts/2 S+ 0:00 | \_ ./python 5611 pts/3 S+ 0:00 \_ grep 5601 After changing the process name: marcelo@marcelo-laptop:~/src/pytrunk$ ps -fax | grep 5601 Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html 5601 pts/2 S+ 0:00 | \_ hello_process_name 5635 pts/3 S+ 0:00 \_ grep 5601 And "killall hello_process_name" works, Gnome Process monitor shows it fine too. By now this is Linux only, but I hope to implement it also for BSD (FreeBSD has it[1], OpenBSD [2] and NetBSD [3] too). [1] http://fxr.watson.org/fxr/source/gen/setproctitle.c?v=FREEBSD-LIBC [2] http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/gen/setproctitle.c?rev=1.11;content-type=text%2Fx-cvsweb-markup [3] http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/gen/setproctitle.c?rev=1.22&content-type=text/x-cvsweb-markup&only_with_tag=MAIN Regards |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2009年04月06日 17:08:13 | marcelo_fernandez | set | recipients: + marcelo_fernandez, loewis, amaury.forgeotdarc, giampaolo.rodola |
| 2009年04月06日 17:08:13 | marcelo_fernandez | set | messageid: <1239037693.19.0.901372393233.issue5672@psf.upfronthosting.co.za> |
| 2009年04月06日 17:08:11 | marcelo_fernandez | link | issue5672 messages |
| 2009年04月06日 17:08:10 | marcelo_fernandez | create | |