Make websockify respect SIGTERM

Child processes were not terminated when the parent websockify
was killed.

This commit makes websockify send a SIGTERM to all active children
when the parent process is terminated.

Fixes #138
This commit is contained in:
Abhishek Kekane 2016-02-03 22:58:21 -08:00 committed by Solly Ross
parent 0b906a1c3e
commit 68b1587ada
1 changed files with 8 additions and 0 deletions

View File

@ -1079,6 +1079,14 @@ class WebSocketServer(object):
except (self.Terminate, SystemExit, KeyboardInterrupt):
self.msg("In exit")
# terminate all child processes
if multiprocessing and not self.run_once:
children = multiprocessing.active_children()
for child in children:
self.msg("Terminating child %s" % child.pid)
child.terminate()
break
except Exception:
exc = sys.exc_info()[1]