Change process name in Python
Linux:
libc6's prctl function with option PR_SET_NAME
PR_SET_NAME (since Linux 2.6.9)
Set the process name for the calling process, using the value in
the location pointed to by (char *) arg2. The name can be up to
16 bytes long, and should be null terminated if it contains
fewer bytes.
code is
import ctypes
libc = ctypes.CDLL('libc.so.6')
libc.prctl(15, '%s\0' %procname, 0, 0, 0)
---------------------------------------------------------------------------------------
BSD:
import dl
libc = dl.open('/lib/libc.so.6')
libc.call('setproctitle', '%s\0' %procname)
---------------------------------------------------------------------------------------
a script to show value of MACRO
echo -e "#include <sys/prctl.h>\n#include <stdio.h>\nint main(){printf(\"%d\\\n\",PR_SET_NAME);return 0;}" |gcc -xc - -o /tmp/test && /tmp/test

