Home > Enterprise >  How to send SIGTERM to a child process using boost::process
How to send SIGTERM to a child process using boost::process

Time:03-03

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?

CodePudding user response:

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

  • Related