websockify does not react to SIGTERM
Child processes are not terminated when parent process of websockify is killed. In this fix made provision to terminate all child processes when parent process is killed. Fixes #138
This commit is contained in:
parent
0b906a1c3e
commit
c8305399cf
|
|
@ -1079,6 +1079,16 @@ class WebSocketServer(object):
|
|||
|
||||
except (self.Terminate, SystemExit, KeyboardInterrupt):
|
||||
self.msg("In exit")
|
||||
# terminate all child processes
|
||||
if multiprocessing and not self.run_once:
|
||||
childs = multiprocessing.active_children()
|
||||
|
||||
for child in childs:
|
||||
pid = child.pid
|
||||
if pid != os.getpid():
|
||||
self.msg("Terminating child %s" % pid)
|
||||
os.kill(pid, signal.SIGTERM)
|
||||
|
||||
break
|
||||
except Exception:
|
||||
exc = sys.exc_info()[1]
|
||||
|
|
|
|||
Loading…
Reference in New Issue