CTF icon indicating copy to clipboard operation
CTF copied to clipboard

Use of `kill -9` in ShutdownCfs leaves xterm process running

Open skliper opened this issue 4 years ago • 1 comments

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)

skliper avatar Nov 04 '21 14:11 skliper

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

skliper avatar Nov 05 '21 12:11 skliper