cron: use prctl to set process name & title (#2524)
This commit is contained in:
parent
57ffd032b2
commit
dfa5675d82
|
@ -18,9 +18,9 @@ import os
|
||||||
import signal
|
import signal
|
||||||
import time
|
import time
|
||||||
try:
|
try:
|
||||||
import dl
|
import prctl
|
||||||
except ImportError:
|
except ImportError:
|
||||||
dl = None
|
prctl = None
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
parent_killed = False
|
parent_killed = False
|
||||||
|
@ -88,17 +88,10 @@ def spawn_cron(create_publisher):
|
||||||
cron_pid = os.fork()
|
cron_pid = os.fork()
|
||||||
if cron_pid == 0:
|
if cron_pid == 0:
|
||||||
pub = create_publisher()
|
pub = create_publisher()
|
||||||
# set process name, this only works on Linux, 15 == PR_SET_NAME
|
# set process name and title (this only works on Linux)
|
||||||
if dl:
|
if prctl:
|
||||||
try:
|
prctl.set_name(os.path.basename(sys.argv[0]) + ' [cron]')
|
||||||
libc = dl.open('/lib/libc.so.6')
|
prctl.set_proctitle(os.path.basename(sys.argv[0]) + ' [cron]')
|
||||||
except dl.error:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
libc.call('prctl', 15, os.path.basename(sys.argv[0]) + ' [cron]\0', 0, 0, 0)
|
|
||||||
except ValueError: # missing symbol
|
|
||||||
pass
|
|
||||||
signal.signal(signal.SIGTERM, stop_cron_process)
|
signal.signal(signal.SIGTERM, stop_cron_process)
|
||||||
cron(pub)
|
cron(pub)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
Loading…
Reference in New Issue