Skip to content

Commit

Permalink
Merge elmirjagudin/buildbot:runprocess-upstart (PR #1173)
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Jul 4, 2014
2 parents 4993679 + 92f583c commit d0d68d3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions slave/buildslave/test/unit/runprocess-scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ def sleep_forever():
time.sleep(10)


def wait_for_parent_death():
def wait_for_parent_death(orig_parent_pid):
while True:
ppid = os.getppid()
if ppid == 1:
if ppid != orig_parent_pid:
return
# on some systems, getppid will keep returning
# a dead pid, so check it for liveness
Expand Down Expand Up @@ -86,8 +86,10 @@ def double_fork():
# parent process exits, so ignore that.
signal.signal(signal.SIGHUP, signal.SIG_IGN)
parent_pidfile, child_pidfile = sys.argv[2:]
parent_pid = os.getpid()

if os.fork() == 0:
wait_for_parent_death()
wait_for_parent_death(parent_pid)
write_pidfile(child_pidfile)
sleep_forever()
else:
Expand Down

0 comments on commit d0d68d3

Please sign in to comment.