mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Delete the lock file on Ctrl-C
This commit is contained in:
parent
ea1b430aea
commit
7ef1dfbe9c
@ -64,10 +64,6 @@ def main():
|
|||||||
# Display OnionShare banner
|
# Display OnionShare banner
|
||||||
print(f"OnionShare {common.version} | https://onionshare.org/")
|
print(f"OnionShare {common.version} | https://onionshare.org/")
|
||||||
|
|
||||||
# Allow Ctrl-C to smoothly quit the program instead of throwing an exception
|
|
||||||
# https://stackoverflow.com/questions/42814093/how-to-handle-ctrlc-in-python-app-with-pyqt
|
|
||||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
|
||||||
|
|
||||||
# Start the Qt app
|
# Start the Qt app
|
||||||
global qtapp
|
global qtapp
|
||||||
qtapp = Application(common)
|
qtapp = Application(common)
|
||||||
@ -147,6 +143,15 @@ def main():
|
|||||||
with open(common.gui.lock_filename, "w") as f:
|
with open(common.gui.lock_filename, "w") as f:
|
||||||
f.write(f"{os.getpid()}\n")
|
f.write(f"{os.getpid()}\n")
|
||||||
|
|
||||||
|
# Allow Ctrl-C to smoothly quit the program instead of throwing an exception
|
||||||
|
def signal_handler(s, frame):
|
||||||
|
print("\nCtrl-C pressed, quitting")
|
||||||
|
if os.path.exists(common.gui.lock_filename):
|
||||||
|
os.remove(common.gui.lock_filename)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
|
|
||||||
# Launch the gui
|
# Launch the gui
|
||||||
main_window = MainWindow(common, filenames)
|
main_window = MainWindow(common, filenames)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user