I am looking for an easy solution to change the title of a python process and the of individual python threads as displayed by top
, htop
or ps
at runtime.
I want to avoid package dependencies but I do not have the requirement for the solution to be portable. It should run on a Gentoo system with Kernel version 4.4.38
and above.
I tried the following which unfortunately did not work on my system.
if sys.platform == 'linux2':
import ctypes
libc = ctypes.cdll.LoadLibrary('libc.so.6')
libc.prctl(15, 'Another Name', 0, 0, 0)