process.send(message[, sendHandle[, options]][, callback])
message
<Object>sendHandle
<net.Server> | <net.Socket>options
<Object> 用于参数化特定类型的句柄的发送。options
支持以下属性:keepOpen
<boolean> 当传递net.Socket
实例时可以使用的值。 当为true
时,则 socket 在发送的过程中会保持打开。 默认值:false
。
callback
<Function>- 返回: <boolean>
如果 Node.js 是使用 IPC 通道衍生的,则可以使用 process.send()
方法发送消息到父进程。
消息会被接收为父进程的 ChildProcess
对象上的 'message'
事件。
如果 Node.js 不是通过 IPC 通道衍生的,则 process.send
会是 undefined
。
消息会进行序列化和解析。 生成的消息可能与最初发送的消息不同。
message
<Object>sendHandle
<net.Server> | <net.Socket>options
<Object> used to parameterize the sending of certain types of handles.options
supports the following properties:keepOpen
<boolean> A value that can be used when passing instances ofnet.Socket
. Whentrue
, the socket is kept open in the sending process. Default:false
.
callback
<Function>- Returns: <boolean>
If Node.js is spawned with an IPC channel, the process.send()
method can be
used to send messages to the parent process. Messages will be received as a
'message'
event on the parent's ChildProcess
object.
If Node.js was not spawned with an IPC channel, process.send
will be
undefined
.
The message goes through serialization and parsing. The resulting message might not be the same as what is originally sent.