Fixed an issue when Ctrl+C(SIGINT) terminates debugging session instead of halting // Resolve #2733

This commit is contained in:
Ivan Kravets
2019-07-04 17:47:26 +03:00
parent d9b6842b6a
commit caf5159002
4 changed files with 23 additions and 1 deletions
+11 -1
View File
@@ -15,6 +15,7 @@
import os
from os.path import isdir, isfile, join
from twisted.internet import error # pylint: disable=import-error
from twisted.internet import reactor # pylint: disable=import-error
from platformio import exception, util
@@ -31,6 +32,7 @@ class DebugServer(BaseProcess):
self._debug_port = None
self._transport = None
self._process_ended = False
def spawn(self, patterns): # pylint: disable=too-many-branches
systype = util.get_systype()
@@ -108,6 +110,14 @@ class DebugServer(BaseProcess):
def get_debug_port(self):
return self._debug_port
def processEnded(self, reason):
self._process_ended = True
super(DebugServer, self).processEnded(reason)
def terminate(self):
if self._transport:
if self._process_ended or not self._transport:
return
try:
self._transport.signalProcess("KILL")
except (OSError, error.ProcessExitedAlready):
pass