仅使用 pid 向分叉 child_process 发送消息

Messaging a forked child_process with just the pid

我有一个主进程生成 child_processes 用于长时间作业。

我希望能够轮询进程以获取有关完成任务的更新,但我所拥有的只是它们的 pid。如何向nodejs中的特定进程发送消息?

如果您正在使用 child_process.fork(),我假设您是 ),您可以使用 child.send() 向子进程发送消息: http://nodejs.org/api/child_process.html#child_process_child_send_message_sendhandle

但是,无法直接检索给定 PID 的子进程对象。