From 428de3cf4250f724894870ccc44bcc4fb3f3e269 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Sat, 17 May 2014 14:02:30 +0800 Subject: [PATCH] signal children --- shadowsocks/server.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/shadowsocks/server.py b/shadowsocks/server.py index 63363d8..180243a 100755 --- a/shadowsocks/server.py +++ b/shadowsocks/server.py @@ -279,6 +279,13 @@ def main(): else: children.append(r) if not is_child: + def handler(signum, frame): + for pid in children: + os.kill(pid, signum) + os.waitpid(pid, 0) + sys.exit() + import signal + signal.signal(signal.SIGTERM, handler) # master for child in children: os.waitpid(child, 0)