doc: describe process API for IPC · nodejs/node@432cce6

@@ -70,6 +70,16 @@ Example of listening for `exit`:

7070

});

7171727273+

## Event: 'message'

74+75+

* `message` {Object} a parsed JSON object or primitive value

76+

* `sendHandle` {Handle object} a [net.Socket][] or [net.Server][] object, or

77+

undefined.

78+79+

Messages sent by [ChildProcess.send()][] are obtained using the `'message'`

80+

event on the child's process object.

81+82+7383

## Event: 'beforeExit'

74847585

This event is emitted when Node.js empties its event loop and has nothing else to

@@ -904,6 +914,38 @@ a diff reading, useful for benchmarks and measuring intervals:

904914

}, 1000);

905915906916917+

## process.send(message[, sendHandle][, callback])

918+919+

* `message` {Object}

920+

* `sendHandle` {Handle object}

921+922+

When Node.js is spawned with an IPC channel attached, it can send messages to its

923+

parent process using `process.send()`. Each will be received as a

924+

['message'](child_process.html#child_process_event_message)

925+

event on the parent's `ChildProcess` object.

926+927+

If io.js was not spawned with an IPC channel, `process.send()` will be undefined.

928+929+930+

## process.disconnect()

931+932+

Close the IPC channel to the parent process, allowing this child to exit

933+

gracefully once there are no other connections keeping it alive.

934+935+

Identical to the parent process's

936+

[ChildProcess.disconnect()](child_process.html#child_process_child_disconnect).

937+938+

If io.js was not spawned with an IPC channel, `process.disconnect()` will be

939+

undefined.

940+941+942+

### process.connected

943+944+

* {Boolean} Set to false after `process.disconnect()` is called

945+946+

If `process.connected` is false, it is no longer possible to send messages.

947+948+907949

## process.mainModule

908950909951

Alternate way to retrieve

@@ -915,4 +957,7 @@ to the same module.

915957916958

As with `require.main`, it will be `undefined` if there was no entry script.

917959960+

[ChildProcess.send()]: child_process.html#child_process_child_send_message_sendhandle_callback

918961

[EventEmitter]: events.html#events_class_events_eventemitter

962+

[net.Server]: net.html#net_class_net_server

963+

[net.Socket]: net.html#net_class_net_socket