Skip to content

Commit

Permalink
Merge pull request #124 from br0ch0n/stale_pid
Browse files Browse the repository at this point in the history
Clean up stale pid.  Fixes #122
  • Loading branch information
Deconstrained authored Dec 12, 2018
2 parents bc25305 + 9827d98 commit fa4a4f7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pdagent/thirdparty/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import atexit
import os
import sys
import psutil


def daemonize(
Expand All @@ -42,9 +43,11 @@ def daemonize(
except (IOError, ValueError):
pid = None

if pid:
message = "pidfile %s already exists. Is it already running?\n"
if (pid and psutil.pid_exists(pid)):
message = "pidfile %s already exists and the process is running!\n"
raise SystemExit(message % pidfile)
if pid:
os.remove(pidfile)

# Do first fork
try:
Expand Down

0 comments on commit fa4a4f7

Please sign in to comment.