Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to send SIGTERM to a child process using boost::process

boost/process.hpp provides a nice mechanism to spawn and manage processes.

It provides a child.terminate() method to send SIGKILL to a child.

How would I alternatively send SIGINT or SIGTERM to a child process?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Looks like you can do:

#include <boost/process/child.hpp>

pid_t pid = my_child.id ();
kill (pid, SIGINT);

The documentation states that id is a private member function, but in practise it seems not to be.

There’s also:

native_handle_t native_handle() const;

But what that actually returns isn’t documented. On Windows it’s most likely a process handle, but on *nix there’s no such thing of course.

… And Ted beat me to it 🙂

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading