Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
Exit on SIGHUP signal (#129)
Browse files Browse the repository at this point in the history
* exit on SIGHUP signal
* Fixes #128
  • Loading branch information
DonJayamanne authored Feb 28, 2018
1 parent e1ff23f commit 5db5cf6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ptvsd/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import errno
import os
import platform
import signal
import socket
import sys
import threading
Expand Down Expand Up @@ -969,6 +970,10 @@ def exit_handler(proc, server_thread):
if server_thread.is_alive():
server_thread.join(WAIT_FOR_THREAD_FINISH_TIMEOUT)

def signal_handler(signum, frame, proc):
proc.close()
sys.exit(0)

def start_server(port):
"""Return a socket to a (new) local pydevd-handling daemon.
Expand All @@ -981,6 +986,8 @@ def start_server(port):
client, _ = server.accept()
pydevd, proc, server_thread = _start(client, server)
atexit.register(lambda: exit_handler(proc, server_thread))
if platform.system() != 'Windows':
signal.signal(signal.SIGHUP, lambda signum, frame: signal_handler(signum, frame, proc))
return pydevd


Expand All @@ -996,6 +1003,8 @@ def start_client(host, port):
client.connect((host, port))
pydevd, proc, server_thread = _start(client, None)
atexit.register(lambda: exit_handler(proc, server_thread))
if platform.system() != 'Windows':
signal.signal(signal.SIGHUP, lambda signum, frame: signal_handler(signum, frame, proc))
return pydevd


Expand Down

0 comments on commit 5db5cf6

Please sign in to comment.