Skip to content

Commit 68b1587

Browse files
abhishekkekaneDirectXMan12
authored andcommitted
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
1 parent 0b906a1 commit 68b1587

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

websockify/websocket.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,14 @@ def start_server(self):
10791079

10801080
except (self.Terminate, SystemExit, KeyboardInterrupt):
10811081
self.msg("In exit")
1082+
# terminate all child processes
1083+
if multiprocessing and not self.run_once:
1084+
children = multiprocessing.active_children()
1085+
1086+
for child in children:
1087+
self.msg("Terminating child %s" % child.pid)
1088+
child.terminate()
1089+
10821090
break
10831091
except Exception:
10841092
exc = sys.exc_info()[1]

0 commit comments

Comments
 (0)