mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Merge branch 'cleanup-after-exit' of https://github.com/r4v5/onionshare into r4v5-cleanup-after-exit
This commit is contained in:
commit
a3fb7a930b
@ -246,6 +246,8 @@ def start_hidden_service(port):
|
|||||||
else:
|
else:
|
||||||
hidserv_dir = "/tmp/onionshare_{0}".format(hidserv_dir_rand)
|
hidserv_dir = "/tmp/onionshare_{0}".format(hidserv_dir_rand)
|
||||||
|
|
||||||
|
register_cleanup_handler(hidserv_dir)
|
||||||
|
|
||||||
# connect to the tor controlport
|
# connect to the tor controlport
|
||||||
controlports = [9051, 9151]
|
controlports = [9051, 9151]
|
||||||
controller = False
|
controller = False
|
||||||
@ -303,6 +305,16 @@ def tails_root():
|
|||||||
while True:
|
while True:
|
||||||
time.sleep(1)
|
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():
|
def main():
|
||||||
load_strings()
|
load_strings()
|
||||||
tails_root()
|
tails_root()
|
||||||
|
Loading…
Reference in New Issue
Block a user