mirror of
https://github.com/onionshare/onionshare.git
synced 2025-06-06 05:49:16 -04:00
Delete the lock file on Ctrl-C
This commit is contained in:
parent
d2517681af
commit
d1143504ac
1 changed files with 9 additions and 4 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue