Commit 3a25f709 authored by Avery Pennarun's avatar Avery Pennarun

log(): don't abort if we fail to write to stderr.

Failing to write to the log sucks, but not as much as failing to clean up
just because stderr disappeared.  So let's catch any IOError exception from
log() and just ignore it.

This should fix a problem reported by Camille Moncelier, which is that
sshuttle firewall entries stick around if your tty dies strangely (eg. your
X server aborts for some reason).
parent a8b3d698
......@@ -4,9 +4,14 @@ logprefix = ''
verbose = 0
def log(s):
sys.stdout.flush()
sys.stderr.write(logprefix + s)
sys.stderr.flush()
try:
sys.stdout.flush()
sys.stderr.write(logprefix + s)
sys.stderr.flush()
except IOError:
# this could happen if stderr gets forcibly disconnected, eg. because
# our tty closes. That sucks, but it's no reason to abort the program.
pass
def debug1(s):
if verbose >= 1:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment