mirror of
/repos/baseimage-docker.git
synced 2025-12-30 08:01:31 +01:00
Fix my_init not properly forcing Runit to shut down if Runit appears to refuse to respond to SIGTERM.
This commit is contained in:
parent
367cddb201
commit
1684aa1448
@ -1,6 +1,7 @@
|
|||||||
## 0.9.8
|
## 0.9.8
|
||||||
|
|
||||||
* Fixed a regression in `my_init` which causes it to delete environment variables passed from Docker.
|
* Fixed a regression in `my_init` which causes it to delete environment variables passed from Docker.
|
||||||
|
* Fixed `my_init` not properly forcing Runit to shut down if Runit appears to refuse to respond to SIGTERM.
|
||||||
|
|
||||||
## 0.9.7 (release date: 2014-02-25)
|
## 0.9.7 (release date: 2014-02-25)
|
||||||
|
|
||||||
|
|||||||
@ -94,6 +94,13 @@ def shquote(s):
|
|||||||
def waitpid_reap_other_children(pid):
|
def waitpid_reap_other_children(pid):
|
||||||
done = False
|
done = False
|
||||||
status = None
|
status = None
|
||||||
|
try:
|
||||||
|
this_pid, status = os.waitpid(pid, os.WNOHANG)
|
||||||
|
except OSError as e:
|
||||||
|
if e.errno == errno.ECHILD or e.errno == errno.ESRCH:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
raise
|
||||||
while not done:
|
while not done:
|
||||||
this_pid, status = os.waitpid(-1, 0)
|
this_pid, status = os.waitpid(-1, 0)
|
||||||
done = this_pid == pid
|
done = this_pid == pid
|
||||||
@ -135,6 +142,9 @@ def run_command_killable(*argv):
|
|||||||
stop_child_process(filename, pid)
|
stop_child_process(filename, pid)
|
||||||
raise
|
raise
|
||||||
if status != 0:
|
if status != 0:
|
||||||
|
if status is None:
|
||||||
|
error("%s exited with unknown exit code\n" % filename)
|
||||||
|
else:
|
||||||
error("%s failed with exit code %d\n" % (filename, status))
|
error("%s failed with exit code %d\n" % (filename, status))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@ -232,12 +242,20 @@ def main(args):
|
|||||||
if len(args.main_command) == 0:
|
if len(args.main_command) == 0:
|
||||||
runit_exited, exit_code = wait_for_runit_or_interrupt(runit_pid)
|
runit_exited, exit_code = wait_for_runit_or_interrupt(runit_pid)
|
||||||
if runit_exited:
|
if runit_exited:
|
||||||
|
if exit_code is None:
|
||||||
|
info("Runit exited with unknown exit code")
|
||||||
|
exit_code = 1
|
||||||
|
else:
|
||||||
info("Runit exited with code %d" % exit_code)
|
info("Runit exited with code %d" % exit_code)
|
||||||
else:
|
else:
|
||||||
info("Running %s..." % " ".join(args.main_command))
|
info("Running %s..." % " ".join(args.main_command))
|
||||||
pid = os.spawnvp(os.P_NOWAIT, args.main_command[0], args.main_command)
|
pid = os.spawnvp(os.P_NOWAIT, args.main_command[0], args.main_command)
|
||||||
try:
|
try:
|
||||||
exit_code = waitpid_reap_other_children(pid)
|
exit_code = waitpid_reap_other_children(pid)
|
||||||
|
if exit_code is None:
|
||||||
|
info("%s exited with unknown exit code." % args.main_command[0])
|
||||||
|
exit_code = 1
|
||||||
|
else:
|
||||||
info("%s exited with exit code %d." % (args.main_command[0], exit_code))
|
info("%s exited with exit code %d." % (args.main_command[0], exit_code))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
stop_child_process(args.main_command[0], pid)
|
stop_child_process(args.main_command[0], pid)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user