Clean up tmpdir storing hidden service info after exit.

This commit is contained in:
Mason Donahue 2014-08-23 18:03:36 -05:00
parent 60d97cfa5e
commit 91d0bb4fda

View File

@ -245,6 +245,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
@ -302,6 +304,15 @@ def tails_root():
while True:
time.sleep(1)
def register_cleanup_handler(directory):
import signal
def handler(signum = None, frame = None):
subprocess.call(['rm','-r',directory])
sys.exit()
for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]:
signal.signal(sig, handler)
def main():
load_strings()
tails_root()