Open skliper opened 2 years ago
Another related challenge... there's cases where the cfs executable is already stopped at the end of the test, but shutdown should still kill the xterm instead of just throwing the error and returning. I ended up just simplifying locally and changing errors to info:
# check whether cFS instance exists
pidof_cfs = "pidof {}".format(self.config.cfs_run_cmd)
pid = run(pidof_cfs, stdout=PIPE, stderr=STDOUT, shell=True, check=False).stdout.decode()
if pid == "":
log.info("CFS executable {} had already terminated!".format(self.config.cfs_run_cmd))
#self.cfs_process_list = []
#self.cfs_running = False
#return True
# clean up any related remaining processes (xterm typically)
kill_string = "pkill -f {}".format(self.config.cfs_exe)
os.system(kill_string)
self.cfs_process_list = []
self.cfs_running = False
return True
https://github.com/nasa/CTF/blob/31c9bef68f05d6ad4ee27a788ac2b6b8de627e71/plugins/cfs/pycfs/cfs_controllers.py#L586-L589
This only kills the cfs process, need to also kill the xterm. One approach that has worked for us is to use pkill:
pkill -f (process name that is also in xterm title)