Created
December 29, 2011 20:59
-
-
Save dnozay/1536167 to your computer and use it in GitHub Desktop.
set/get process name (using ctypes & prctl)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set/get process name (using ctypes & prctl) | |
# set_proc_name('python rocks') | |
# name = get_proc_name() | |
import ctypes | |
from ctypes.util import find_library | |
libc = ctypes.CDLL(find_library('c')) | |
PR_SET_NAME = 15 | |
PR_GET_NAME = 16 | |
def set_proc_name(name): | |
libc.prctl(PR_SET_NAME, ctypes.c_char_p(name), 0, 0, 0) | |
def get_proc_name(): | |
name = ctypes.create_string_buffer(16) | |
libc.prctl(PR_GET_NAME, name, 0, 0, 0) | |
return name.value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment