-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Worker and child processes now get named
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
try: | ||
import procname | ||
setprocname = procname.setprocname | ||
getprocname = procname.getprocname | ||
except ImportError: | ||
try: | ||
from ctypes import cdll, byref, create_string_buffer | ||
libc = cdll.LoadLibrary('libc.so.6') | ||
def setprocname(name): | ||
buff = create_string_buffer(len(name)+1) | ||
buff.value = name | ||
libc.prctl(15, byref(buff), 0, 0, 0) | ||
# FreeBSD: libc.setproctitle(name) | ||
def getprocname(): | ||
libc = cdll.LoadLibrary('libc.so.6') | ||
buff = create_string_buffer(128) | ||
# 16 == PR_GET_NAME from <linux/prctl.h> | ||
libc.prctl(16, byref(buff), 0, 0, 0) | ||
return buff.value | ||
except (OSError, ImportError): | ||
def setprocname(name): | ||
pass | ||
def getprocname(): | ||
import sys | ||
return sys.argv[0] |
This file contains 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