Skip to content

Commit

Permalink
testrunnerplugin: Use pid of the process that has the listener
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikko Korpela committed Aug 21, 2012
1 parent 6734683 commit 3a4f6e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/robotide/contrib/testrunner/SocketListener.py
Expand Up @@ -23,6 +23,9 @@
import os
import socket
import sys
import signal
import time

try:
import cPickle as pickle
except ImportError:
Expand Down
10 changes: 4 additions & 6 deletions src/robotide/contrib/testrunner/testrunnerplugin.py
Expand Up @@ -280,7 +280,7 @@ def OnStop(self, event):
same effect as typing control-c when running from the
command line."""
if self._process:
self._process.kill()
self._process.kill(pid_to_kill=self._pid_to_kill)

def OnRun(self, event):
'''Called when the user clicks the "Run" button'''
Expand Down Expand Up @@ -962,21 +962,19 @@ def get_errors(self):
def is_alive(self):
return self._process.poll() is None

def kill(self, force=False):
def kill(self, force=False, pid_to_kill=None):
if not self._process:
return
if force:
self._process.kill()
pid = self._process.pid
pid = pid_to_kill or self._process.pid
if pid:
try:
if os.name == 'nt' and sys.version_info < (2,7):
import ctypes
ctypes.windll.kernel32.TerminateProcess(int(self._process._handle), -1)
elif IS_WINDOWS:
os.kill(pid, signal.CTRL_BREAK_EVENT)
else:
os.killpg(pid, signal.SIGINT)
os.kill(pid, signal.SIGINT)
except OSError:
pass
return pid
Expand Down

0 comments on commit 3a4f6e4

Please sign in to comment.