| 75 | |
| 76 | |
| 77 | def firewall_exit(signum, frame): |
| 78 | # The typical sshuttle exit is that the main sshuttle process |
| 79 | # exits, closes file descriptors it uses, and the firewall process |
| 80 | # notices that it can't read from stdin anymore and exits |
| 81 | # (cleaning up firewall rules). |
| 82 | # |
| 83 | # However, in some cases, Ctrl+C might get sent to the firewall |
| 84 | # process. This might caused if someone manually tries to kill the |
| 85 | # firewall process, or if sshuttle was started using sudo's use_pty option |
| 86 | # and they try to exit by pressing Ctrl+C. Here, we forward the |
| 87 | # Ctrl+C/SIGINT to the main sshuttle process which should trigger |
| 88 | # the typical exit process as described above. |
| 89 | if sshuttle_pid: |
| 90 | debug1("Relaying interupt signal to sshuttle process %d" % sshuttle_pid) |
| 91 | if sys.platform == 'win32': |
| 92 | sig = signal.CTRL_C_EVENT |
| 93 | else: |
| 94 | sig = signal.SIGINT |
| 95 | os.kill(sshuttle_pid, sig) |
| 96 | |
| 97 | |
| 98 | def _setup_daemon_for_unix_like(): |