From e2c682084c798f8f252b0e5167d2cc412061344f Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Thu, 5 Jan 2012 21:16:24 -0500 Subject: [PATCH] firewall: catch SIGHUP and SIGPIPE. Not sure if this will fix anything, but it might stop the problem reported on some MacOS versions where the firewall doesn't get cleaned up correctly. --- firewall.py | 7 ++++++- main.py | 0 2 files changed, 6 insertions(+), 1 deletion(-) mode change 100644 => 100755 main.py diff --git a/firewall.py b/firewall.py index 1eda23d..98f0fe0 100644 --- a/firewall.py +++ b/firewall.py @@ -1,4 +1,4 @@ -import re, errno, socket, select, struct +import re, errno, socket, select, signal, struct import compat.ssubprocess as ssubprocess import helpers, ssyslog from helpers import * @@ -398,6 +398,11 @@ def main(port, dnsport, syslog): sys.stdout.write('READY\n') sys.stdout.flush() + # don't disappear if our controlling terminal or stdout/stderr + # disappears; we still have to clean up. + signal.signal(signal.SIGHUP, signal.SIG_IGN) + signal.signal(signal.SIGPIPE, signal.SIG_IGN) + # ctrl-c shouldn't be passed along to me. When the main sshuttle dies, # I'll die automatically. os.setsid() diff --git a/main.py b/main.py old mode 100644 new mode 100755