mirror of
/repos/baseimage-docker.git
synced 2025-12-31 08:11:29 +01:00
Correctly reap child processes that are adopted during invocation of init scripts.
This commit is contained in:
parent
67c6b089e3
commit
c22f8804ad
@ -1,3 +1,7 @@
|
|||||||
|
## 0.9.6
|
||||||
|
|
||||||
|
* Fixed a bug in `my_init`: child processes that have been adopted during execution of init scripts are now properly reaped.
|
||||||
|
|
||||||
## 0.9.5 (release date: 2014-02-06)
|
## 0.9.5 (release date: 2014-02-06)
|
||||||
|
|
||||||
* Environment variables are now no longer reset by runit. This is achieved by running `runsvdir` directly instead of through Debian's `runsvdir-start`.
|
* Environment variables are now no longer reset by runit. This is achieved by running `runsvdir` directly instead of through Debian's `runsvdir-start`.
|
||||||
|
|||||||
@ -29,8 +29,7 @@ def reap_child(signum, frame):
|
|||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def stop_child_process(name):
|
def stop_child_process(name, pid):
|
||||||
global pid
|
|
||||||
print("*** Shutting down %s (PID %d)..." % (name, pid))
|
print("*** Shutting down %s (PID %d)..." % (name, pid))
|
||||||
try:
|
try:
|
||||||
os.kill(pid, signal.SIGHUP)
|
os.kill(pid, signal.SIGHUP)
|
||||||
@ -41,10 +40,14 @@ def run_command_killable(*argv):
|
|||||||
global pid
|
global pid
|
||||||
filename = argv[0]
|
filename = argv[0]
|
||||||
pid = os.spawnvp(os.P_NOWAIT, filename, argv)
|
pid = os.spawnvp(os.P_NOWAIT, filename, argv)
|
||||||
signal.signal(signal.SIGINT, lambda signum, frame: stop_child_process(filename))
|
signal.signal(signal.SIGINT, lambda signum, frame: stop_child_process(filename, pid))
|
||||||
signal.signal(signal.SIGTERM, lambda signum, frame: stop_child_process(filename))
|
signal.signal(signal.SIGTERM, lambda signum, frame: stop_child_process(filename, pid))
|
||||||
try:
|
try:
|
||||||
this_pid, status = os.waitpid(pid, 0)
|
done = False
|
||||||
|
while not done:
|
||||||
|
try:
|
||||||
|
this_pid, status = os.waitpid(-1, 0)
|
||||||
|
done = this_pid == pid
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.errno == errno.EINTR:
|
if e.errno == errno.EINTR:
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
@ -74,7 +77,7 @@ signal.signal(signal.SIGCHLD, reap_child)
|
|||||||
print("*** Booting runit...")
|
print("*** Booting runit...")
|
||||||
pid = os.spawnl(os.P_NOWAIT, "/usr/bin/runsvdir", "/usr/bin/runsvdir", "-P", "/etc/service", "log: %s" % ('.' * 395))
|
pid = os.spawnl(os.P_NOWAIT, "/usr/bin/runsvdir", "/usr/bin/runsvdir", "-P", "/etc/service", "log: %s" % ('.' * 395))
|
||||||
print("*** Runit started as PID %d" % pid)
|
print("*** Runit started as PID %d" % pid)
|
||||||
signal.signal(signal.SIGTERM, lambda signum, frame: stop_child_process("runit"))
|
signal.signal(signal.SIGTERM, lambda signum, frame: stop_child_process("runit", pid))
|
||||||
|
|
||||||
# Wait for runit, and while waiting, reap any adopted orphans.
|
# Wait for runit, and while waiting, reap any adopted orphans.
|
||||||
done = False
|
done = False
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user