def set_proc_name(newname):
'''Set the process name seen by the OS in ps, for example
'''
log("Entering {0}.".format(sys._getframe().f_code.co_name), level='DEBUG')
# This works on EOS but not on OSX. Wrapped in try for testability.
try:
libc = cdll.LoadLibrary('libc.so.6')
buff = create_string_buffer(len(newname) + 1)
buff.value = newname
libc.prctl(15, byref(buff), 0, 0, 0)
except:
log("Unable to set process name", level='DEBUG')
if DEBUG:
print "proc_name: {0}\n".format(sys.argv[0])
评论列表
文章目录