From 13d801a14a037fc02264ba0416cd1be68800a12e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 22 Feb 2013 09:15:20 +0100 Subject: [PATCH] cron: use prctl to set process name & title (#2524) --- wcs/qommon/cron.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/wcs/qommon/cron.py b/wcs/qommon/cron.py index 53bedf1..1e6939f 100644 --- a/wcs/qommon/cron.py +++ b/wcs/qommon/cron.py @@ -18,9 +18,9 @@ import os import signal import time try: - import dl + import prctl except ImportError: - dl = None + prctl = None import sys parent_killed = False @@ -95,17 +95,10 @@ def spawn_cron(create_publisher): if cron_pid == 0: # create a fake publisher pub = create_publisher() - # set process name, this only works on Linux, 15 == PR_SET_NAME - if dl: - try: - libc = dl.open('/lib/libc.so.6') - 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 + # set process name and title (this only works on Linux) + if prctl: + prctl.set_name(os.path.basename(sys.argv[0]) + ' [cron]') + prctl.set_proctitle(os.path.basename(sys.argv[0]) + ' [cron]') signal.signal(signal.SIGTERM, stop_cron_process) cron(pub) sys.exit(0) -- 1.7.10.4