Skip to content

Commit

Permalink
Signal handling
Browse files Browse the repository at this point in the history
  • Loading branch information
maouw committed Sep 28, 2023
1 parent bd4aba0 commit dd719e1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions hyakvnc/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def cmd_create(container_path: Union[str, Path], dry_run=False) -> Union[HyakVnc
:return: None
"""

def kill_self(sig=signal.SIGSTOP):
def kill_self(sig=signal.SIGTERM):
os.kill(os.getpid(), sig)

def cancel_created_jobs():
Expand All @@ -62,7 +62,9 @@ def create_node_signal_handler(signal_number, frame):
exit(1)

signal.signal(signal.SIGINT, create_node_signal_handler)
signal.signal(signal.SIGTSTP, create_node_signal_handler)
signal.signal(signal.SIGSTOP, create_node_signal_handler)
signal.signal(signal.SIGTERM, create_node_signal_handler)

container_path = Path(container_path)
container_name = container_path.stem

Expand Down Expand Up @@ -209,7 +211,9 @@ def signal_handler(signal_number, frame):
exit(1)

signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTSTP, signal_handler)
signal.signal(signal.SIGSTOP, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)

logger.info("Finding running VNC jobs...")

vnc_sessions = HyakVncSession.find_running_sessions(app_config)
Expand All @@ -231,7 +235,9 @@ def signal_handler(signal_number, frame):
exit(1)

signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTSTP, signal_handler)
signal.signal(signal.SIGSTOP, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)


assert (job_id is not None) ^ (session is not None), "Must specify either a job id or session"

Expand Down

0 comments on commit dd719e1

Please sign in to comment.