Don't trust argv when deciding if duplicate.

parent 0a5071e9
...@@ -144,13 +144,10 @@ def setRunning(pid_file): ...@@ -144,13 +144,10 @@ def setRunning(pid_file):
pid = None pid = None
# XXX This could use psutil library. # XXX This could use psutil library.
if pid is not None and os.path.exists("/proc/%s" % pid): if pid is not None and os.path.exists("/proc/%s" % pid):
#XXX: can we trust sys.argv? # In case process is present, ignore.
process_name = os.path.basename(sys.argv[0]) logger.warning('New slapos process started, but another slapgrid '
if process_name in open('/proc/%s/cmdline' % pid, 'r').readline(): 'process is aleady running with pid %s, exiting.' % pid)
# In case process is present, ignore. sys.exit(10)
logger.warning('New slapos process started, but another slapgrid '
'process is aleady running with pid %s, exiting.' % pid)
sys.exit(10)
logger.info('Existing pid file %r was stale one, overwritten' % pid_file) logger.info('Existing pid file %r was stale one, overwritten' % pid_file)
# Start new process # Start new process
write_pid(pid_file) write_pid(pid_file)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment