stopping rosbag record from script
I have a python subprocess that starts recording a topic through rosbag:
self.ros_bag_recorder = subprocess.Popen(['rosbag', 'record', '-O',
os.path.expanduser('~/some_address),
'/the_topic'],
env=self.venv,
stdout=subprocess.PIPE,
stderr=sys.stderr
)
which normally I would have executed in a terminal and after pressing ctrl+c the recording was stopped ( the bag file from .bag.active would have changed to .bag). However now that I have started it through suprocess and want to also stop it with an script rather than terminal, commands such as followings haven't worked:
self.ros_bag_recorder.send_signal(signal.SIGTERM)
or
self.ros_bag_recorder.send_signal(signal.SIGKILL)
or
self.ros_bag_recorder.send_signal(signal.SIGINT)
Does anyone know a way to stop the recording similar to when we just press ctrl+c in terminal?