subprocess.disconnect()
关闭父子进程之间的 IPC 通道,当没有其他连接维持子进程存活时,允许子进程正常退出。调用此方法后,父子进程中的 subprocess.connected 和 process.connected 属性将分别被设置为 false,并且无法再在进程之间传递消息。
【Closes the IPC channel between parent and child processes, allowing the child
process to exit gracefully once there are no other connections keeping it alive.
After calling this method the subprocess.connected and
process.connected properties in both the parent and child processes
(respectively) will be set to false, and it will be no longer possible
to pass messages between the processes.】
当没有消息正在接收时,将触发 'disconnect' 事件。这通常会在调用 subprocess.disconnect() 后立即触发。
【The 'disconnect' event will be emitted when there are no messages in the
process of being received. This will most often be triggered immediately after
calling subprocess.disconnect().】
当子进程是 Node.js 实例时(例如使用 child_process.fork() 创建的),可以在子进程中调用 process.disconnect() 方法来关闭 IPC 通道。
【When the child process is a Node.js instance (e.g. spawned using
child_process.fork()), the process.disconnect() method can be invoked
within the child process to close the IPC channel as well.】