summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolly Ross <sross@redhat.com>2014-01-30 17:24:42 -0500
committerSolly Ross <sross@redhat.com>2014-01-30 17:26:17 -0500
commit3ee9ff7f4d5b27c77c75e246d4ac8d642049b02f (patch)
tree1647b3ed937cef8de1dca5b2fd39750059bb35e7
parent18e70c52e1982e2d5fe72b04e12449c250aaff32 (diff)
downloadwebsockify-bug/108-no-sigchld-in-windows.tar.gz
Work around lack of SIGCHLD on Windowsbug/108-no-sigchld-in-windows
This only enables the SIGCHLD handler if SIGCHLD exists, such that platforms without SIGCHLD (such as windows) can still run websockify natively. See #108
-rw-r--r--websockify/websocket.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/websockify/websocket.py b/websockify/websocket.py
index 889bc40..b891c52 100644
--- a/websockify/websocket.py
+++ b/websockify/websocket.py
@@ -913,17 +913,21 @@ class WebSocketServer(object):
original_signals = {
signal.SIGINT: signal.getsignal(signal.SIGINT),
signal.SIGTERM: signal.getsignal(signal.SIGTERM),
- signal.SIGCHLD: signal.getsignal(signal.SIGCHLD),
}
+ if getattr(signal, 'SIGCHLD', None) is not None:
+ original_signals[signal.SIGCHLD] = signal.getsignal(signal.SIGCHLD),
+
signal.signal(signal.SIGINT, self.do_SIGINT)
signal.signal(signal.SIGTERM, self.do_SIGTERM)
- if not multiprocessing:
- # os.fork() (python 2.4) child reaper
- signal.signal(signal.SIGCHLD, self.fallback_SIGCHLD)
- else:
- # make sure that _cleanup is called when children die
- # by calling active_children on SIGCHLD
- signal.signal(signal.SIGCHLD, self.multiprocessing_SIGCHLD)
+
+ if getattr(signal, 'SIGCHLD', None) is not None:
+ if not multiprocessing:
+ # os.fork() (python 2.4) child reaper
+ signal.signal(signal.SIGCHLD, self.fallback_SIGCHLD)
+ else:
+ # make sure that _cleanup is called when children die
+ # by calling active_children on SIGCHLD
+ signal.signal(signal.SIGCHLD, self.multiprocessing_SIGCHLD)
last_active_time = self.launch_time
try: