Commit 4d045403 authored by Luke Macken's avatar Luke Macken

reverse: Ensure we don't permanently hijack stdout/err or leave sockets open

parent fa2cffe2
......@@ -109,9 +109,10 @@ class ReversePythonConnection(ReverseConnection):
output = buffer.getvalue()
except:
output = traceback.format_exc()
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
buffer.close()
finally:
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
buffer.close()
self.send(output)
return True
......@@ -186,6 +187,6 @@ class ReversePythonShell(threading.Thread, pyrasite.PyrasiteIPC):
pass
except:
traceback.print_exc(file=sys.__stderr__)
sys.stdout, sys.stderr = sys.__stdout__, sys.__stderr__
self.close()
finally:
sys.stdout, sys.stderr = sys.__stdout__, sys.__stderr__
self.close()
......@@ -73,8 +73,8 @@ def shell():
except:
print('')
raise
ipc.close()
finally:
ipc.close()
if __name__ == '__main__':
......
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