如何使用 boost::process 将 SIGTERM 发送到 child 进程

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

boost/process.hpp 提供了一个很好的机制来生成和管理进程。

它提供了一个child.terminate()方法来发送SIGKILL到child。

我如何将 SIGINT 或 SIGTERM 发送到 child 进程?

看起来你可以做到:

#include <boost/process/child.hpp>

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

documentation 声明 id 是一个私有成员函数,但实际上它似乎不是。

还有:

native_handle_t native_handle() const;

但实际上 returns 没有记录。在 Windows 上它很可能是进程句柄,但在 *nix 上当然没有这样的东西。

... 特德抢在我之前:)