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

1.4k Views Asked by At

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?

1

There are 1 best solutions below

8
On BEST ANSWER

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 :)