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

Exit on SIGHUP signal #129

Merged
merged 5 commits into from
Feb 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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