Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions yapdi.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,23 @@ def status(self):
pf = file(self.pidfile,'r')
pid = int(pf.read().strip())
pf.close()

# See if the pidfile matches the calling script name
cmdlinepath = '/proc/%d/cmdline' % pid
if os.path.exists(cmdlinepath):
cmdlinefile = open(cmdlinepath, 'r')
cmdline = cmdlinefile.read()
cmdlinefile.close()

# The pid in our file isn't this script
if not sys.argv[0].split('/')[-1] in cmdline:
self.delpid()
pid = None

# The pid from our pidfile isn't running
else:
self.delpid()
pid = None
except IOError:
pid = None
return pid
Expand Down