def set_process_name(name): """ On Linux systems later than 2.6.9, this function sets the process name as it appears in ps, and so that it can be found with killall. Note: name will be truncated to the cumulative length of the original process name and all its arguments; once updated, passed arguments will no longer be visible. """ cmdline = open('/proc/%s/cmdline' % os.getpid()).readline() _utils.set_process_name(name, len(cmdline))
def set_running(name, modify = True): """ Set this program as running with the given name. If modify is True, the process name is updated as described in set_process_name(). """ cmdline = open('/proc/%s/cmdline' % os.getpid()).readline() run = open(tempfile('run/' + name), 'w') run.write(str(os.getpid()) + '\n') run.write(cmdline) run.close() if modify: _utils.set_process_name(name, len(cmdline))