I have an application that I execute in terminal by through the following command:
rosbag record -O /home/user/some_address/file /topic
which makes a file.bag.active
in the above address and basically record some information inside it.
After a while by pressing ctrl+c in the terminal the file.bag.active
changes to file.bag
and will be ready to be read by another application.
Yet, I want to make this sequence done by a python script for which the best way seems doing the following:
import subprocess, shlex
command = "rosbag record -O /home/user/some_address/file /topic"
command = shlex.split(command)
self.proc = subprocess.Popen(command)
where another part of the script that is meant to represent the ctrl+c function is:
self.proc.send_signal(subprocess.signal.SIGINT)
However, in this case the file.bag.active
file doesn't change to file.bag
, and I am not sure what else I can do or add to this code that will do so.
What I noticed in addition was that if I add a pdb.set_trace() and press ctrl+c inside it when it is invoked I get the result I look for which I can't explain why or how I can represent such functionality in an automatic code.
Does anyone know a workaround for it?
Got an answer here, that is:
and for the ctrl+c functionality: