Merge branch 'cleanup-after-exit' of https://github.com/r4v5/onionshare into r4v5-cleanup-after-exit

This commit is contained in:
Micah Lee 2014-08-26 15:23:03 -07:00
commit a3fb7a930b

View File

@ -246,6 +246,8 @@ def start_hidden_service(port):
else:
hidserv_dir = "/tmp/onionshare_{0}".format(hidserv_dir_rand)
register_cleanup_handler(hidserv_dir)
# connect to the tor controlport
controlports = [9051, 9151]
controller = False
@ -303,6 +305,16 @@ def tails_root():
while True:
time.sleep(1)
def register_cleanup_handler(directory):
import signal
import shutil
def handler(signum = None, frame = None):
shutil.rmtree(directory)
sys.exit()
for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]:
signal.signal(sig, handler)
def main():
load_strings()
tails_root()