Skip to content

Commit

Permalink
Add signal windows
Browse files Browse the repository at this point in the history
Signed-off-by: Irene Bandera <[email protected]>
  • Loading branch information
irenebm committed Apr 5, 2023
1 parent c278b00 commit 954f24c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions fastddsspy_tool/test/application/test_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import signal
import re
import time
import os

DESCRIPTION = """Script to execute Fast DDS Spy executable test"""
USAGE = ('python3 tests.py -e <path/to/fastddsspy-executable>'
Expand Down Expand Up @@ -138,13 +139,27 @@ def run_dds(self):
stderr=subprocess.PIPE)
return proc

def is_linux(self):
"""Return whether the script is running in a Linux environment."""
return os.name == 'posix'

def is_windows(self):
"""Return whether the script is running in a Windows environment."""
return os.name == 'nt'

def stop_dds(self, proc):
# send a ctrl+c signal to the subprocess
proc.send_signal(signal.SIGINT)
if self.is_linux():
proc.send_signal(signal.SIGINT)
elif self.is_windows():
proc.send_signal(signal.CTRL_C_EVENT)
try:
proc.communicate(timeout=5)
except subprocess.TimeoutExpired:
proc.send_signal(signal.SIGINT)
if self.is_linux():
proc.send_signal(signal.SIGINT)
elif self.is_windows():
proc.send_signal(signal.CTRL_C_EVENT)
proc.communicate()

def valid_returncode(self, returncode):
Expand Down

0 comments on commit 954f24c

Please sign in to comment.