@@ -19,15 +19,15 @@ convenient.
19
19
20
20
## Class: ChildProcess
21
21
22
- ` ChildProcess ` is an [ EventEmitter] [ ] .
22
+ ` ChildProcess ` is an [ ` EventEmitter ` ] [ ] .
23
23
24
24
Child processes always have three streams associated with them. ` child.stdin ` ,
25
25
` child.stdout ` , and ` child.stderr ` . These may be shared with the stdio
26
26
streams of the parent process, or they may be separate stream objects
27
27
which can be piped to and from.
28
28
29
29
The ChildProcess class is not intended to be used directly. Use the
30
- ` spawn() ` , ` exec() ` , ` execFile() ` , or ` fork() ` methods to create a Child
30
+ [ ` spawn() ` ] [ ] , [ ` exec() ` ] [ ] , [ ` execFile() ` ] [ ] , or [ ` fork() ` ] [ ] methods to create a Child
31
31
Process instance.
32
32
33
33
### Event: 'close'
@@ -37,7 +37,7 @@ Process instance.
37
37
was killed by the parent.
38
38
39
39
This event is emitted when the stdio streams of a child process have all
40
- terminated. This is distinct from 'exit', since multiple processes
40
+ terminated. This is distinct from ` 'exit' ` , since multiple processes
41
41
might share the same stdio streams.
42
42
43
43
### Event: 'disconnect'
@@ -56,7 +56,7 @@ Emitted when:
56
56
2 . The process could not be killed, or
57
57
3 . Sending a message to the child process failed for whatever reason.
58
58
59
- Note that the ` exit ` - event may or may not fire after an error has occurred. If
59
+ Note that the ` ' exit' ` event may or may not fire after an error has occurred. If
60
60
you are listening on both events to fire a function, remember to guard against
61
61
calling your function twice.
62
62
@@ -75,20 +75,20 @@ of the signal, otherwise `null`.
75
75
76
76
Note that the child process stdio streams might still be open.
77
77
78
- Also, note that Node.js establishes signal handlers for ` ' SIGINT' ` and
79
- ` ' SIGTERM` ' , so it will not terminate due to receipt of those signals,
78
+ Also, note that Node.js establishes signal handlers for ` SIGINT ` and
79
+ ` SIGTERM ` , so it will not terminate due to receipt of those signals,
80
80
it will exit.
81
81
82
82
See ` waitpid(2) ` .
83
83
84
84
### Event: 'message'
85
85
86
86
* ` message ` {Object} a parsed JSON object or primitive value.
87
- * ` sendHandle ` {Handle object} a [ net.Socket] [ ] or [ net.Server] [ ] object, or
87
+ * ` sendHandle ` {Handle object} a [ ` net.Socket ` ] [ ] or [ ` net.Server ` ] [ ] object, or
88
88
undefined.
89
89
90
90
Messages sent by ` .send(message, [sendHandle]) ` are obtained using the
91
- ` message ` event.
91
+ ` ' message' ` event.
92
92
93
93
### child.connected
94
94
@@ -103,11 +103,11 @@ gracefully once there are no other connections keeping it alive. After calling
103
103
this method the ` .connected ` flag will be set to ` false ` in both the parent and
104
104
child, and it is no longer possible to send messages.
105
105
106
- The 'disconnect' event will be emitted when there are no messages in the process
106
+ The ` 'disconnect' ` event will be emitted when there are no messages in the process
107
107
of being received, most likely immediately.
108
108
109
109
Note that you can also call ` process.disconnect() ` in the child process when the
110
- child process has any open IPC channels with the parent (i.e ` fork() ` ).
110
+ child process has any open IPC channels with the parent (i.e [ ` fork() ` ] [ ] ).
111
111
112
112
### child.kill([ signal] )
113
113
@@ -188,17 +188,17 @@ will emit objects each time it receives a message on its channel.
188
188
189
189
There is a special case when sending a ` {cmd: 'NODE_foo'} ` message. All messages
190
190
containing a ` NODE_ ` prefix in its ` cmd ` property will not be emitted in
191
- the ` message ` event, since they are internal messages used by Node.js core.
192
- Messages containing the prefix are emitted in the ` internalMessage ` event.
191
+ the ` ' message' ` event, since they are internal messages used by Node.js core.
192
+ Messages containing the prefix are emitted in the ` ' internalMessage' ` event.
193
193
Avoid using this feature; it is subject to change without notice.
194
194
195
195
The ` sendHandle ` option to ` child.send() ` is for sending a TCP server or
196
196
socket object to another process. The child will receive the object as its
197
- second argument to the ` message ` event.
197
+ second argument to the ` ' message' ` event.
198
198
199
199
The ` callback ` option is a function that is invoked after the message is
200
200
sent but before the target may have received it. It is called with a single
201
- argument: ` null ` on success, or an ` Error ` object on failure.
201
+ argument: ` null ` on success, or an [ ` Error ` ] [ ] object on failure.
202
202
203
203
` child.send() ` emits an ` 'error' ` event if no callback was given and the message
204
204
cannot be sent, for example because the child process has already exited.
@@ -236,7 +236,7 @@ Note that the server is now shared between the parent and child, this means
236
236
that some connections will be handled by the parent and some by the child.
237
237
238
238
For ` dgram ` servers the workflow is exactly the same. Here you listen on
239
- a ` message ` event instead of ` connection ` and use ` server.bind ` instead of
239
+ a ` ' message' ` event instead of ` ' connection' ` and use ` server.bind ` instead of
240
240
` server.listen ` . (Currently only supported on UNIX platforms.)
241
241
242
242
#### Example: sending socket object
@@ -307,7 +307,7 @@ to the same object, or null.
307
307
* {Array}
308
308
309
309
A sparse array of pipes to the child process, corresponding with positions in
310
- the [ stdio] [ ] option to [ spawn] [ ] that have been set to ` 'pipe' ` .
310
+ the [ ` stdio ` ] [ ] option to [ ` spawn() ` ] [ ] that have been set to ` 'pipe' ` .
311
311
Note that streams 0-2 are also available as ChildProcess.stdin,
312
312
ChildProcess.stdout, and ChildProcess.stderr, respectively.
313
313
@@ -391,7 +391,7 @@ Runs a command in a shell and buffers the output.
391
391
});
392
392
393
393
The callback gets the arguments ` (error, stdout, stderr) ` . On success, ` error `
394
- will be ` null ` . On error, ` error ` will be an instance of ` Error ` and ` error.code `
394
+ will be ` null ` . On error, ` error ` will be an instance of [ ` Error ` ] [ ] and ` error.code `
395
395
will be the exit code of the child process, and ` error.signal ` will be set to the
396
396
signal that terminated the process.
397
397
@@ -451,7 +451,7 @@ leaner than [`child_process.exec()`][]. It has the same options.
451
451
(Default: ` process.execArgv ` )
452
452
* ` silent ` {Boolean} If true, stdin, stdout, and stderr of the child will be
453
453
piped to the parent, otherwise they will be inherited from the parent, see
454
- the " pipe" and " inherit" options for ` spawn() ` 's ` stdio ` for more details
454
+ the ` ' pipe' ` and ` ' inherit' ` options for [ ` spawn() ` ] [ ] 's [ ` stdio ` ] [ ] for more details
455
455
(default is false)
456
456
* ` uid ` {Number} Sets the user identity of the process. (See setuid(2).)
457
457
* ` gid ` {Number} Sets the group identity of the process. (See setgid(2).)
@@ -472,7 +472,7 @@ done with care and by default will talk over the fd represented an
472
472
environmental variable ` NODE_CHANNEL_FD ` on the child process. The input and
473
473
output on this fd is expected to be line delimited JSON objects.
474
474
475
- * Note: Unlike the ` fork() ` POSIX system call, ` child_process.fork() ` does not clone the
475
+ * Note: Unlike the ` fork() ` POSIX system call, [ ` child_process.fork() ` ] [ ] does not clone the
476
476
current process.*
477
477
478
478
### child_process.spawn(command[ , args] [ , options ] )
@@ -613,7 +613,7 @@ As a shorthand, the `stdio` argument may be one of the following strings:
613
613
* ` 'ignore' ` - ` ['ignore', 'ignore', 'ignore'] `
614
614
* ` 'inherit' ` - ` [process.stdin, process.stdout, process.stderr] ` or ` [0,1,2] `
615
615
616
- Otherwise, the 'stdio' option to ` child_process.spawn() ` is an array where each
616
+ Otherwise, the ` 'stdio' ` option to [ ` child_process.spawn() ` ] [ ] is an array where each
617
617
index corresponds to a fd in the child. The value is one of the following:
618
618
619
619
1 . ` 'pipe' ` - Create a pipe between the child process and the parent process.
@@ -697,7 +697,7 @@ the `SIGTERM` signal and doesn't exit, your process will wait until the child
697
697
process has exited.
698
698
699
699
If the process times out, or has a non-zero exit code, this method *** will***
700
- throw. The ` Error ` object will contain the entire result from
700
+ throw. The [ ` Error ` ] [ ] object will contain the entire result from
701
701
[ ` child_process.spawnSync() ` ] [ ]
702
702
703
703
### child_process.execSync(command[ , options] )
@@ -731,7 +731,7 @@ the `SIGTERM` signal and doesn't exit, your process will wait until the child
731
731
process has exited.
732
732
733
733
If the process times out, or has a non-zero exit code, this method *** will***
734
- throw. The ` Error ` object will contain the entire result from
734
+ throw. The [ ` Error ` ] [ ] object will contain the entire result from
735
735
[ ` child_process.spawnSync() ` ] [ ]
736
736
737
737
### child_process.spawnSync(command[ , args] [ , options ] )
@@ -766,16 +766,20 @@ until the process has completely exited. That is to say, if the process handles
766
766
the ` SIGTERM ` signal and doesn't exit, your process will wait until the child
767
767
process has exited.
768
768
769
- [ below ] : #child_process_asynchronous_process_creation
770
- [ synchronous counterparts ] : #child_process_synchronous_process_creation
771
- [ EventEmitter ] : events.html#events_class_events_eventemitter
772
- [ `ChildProcess#kill()` ] : #child_process_child_kill_signal
773
- [ `ChildProcess#send()` ] : #child_process_child_send_message_sendhandle_callback
774
- [ net.Server ] : net.html#net_class_net_server
775
- [ net.Socket ] : net.html#net_class_net_socket
776
- [ `child_process.fork()` ] : #child_process_child_process_fork_modulepath_args_options
777
- [ stdio ] : #child_process_options_stdio
778
- [ spawn ] : #child_process_child_process_spawn_command_args_options
779
769
[ `child_process.exec()` ] : #child_process_child_process_exec_command_options_callback
770
+ [ `child_process.fork()` ] : #child_process_child_process_fork_modulepath_args_options
780
771
[ `child_process.spawn()` ] : #child_process_child_process_spawn_command_args_options
781
772
[ `child_process.spawnSync()` ] : #child_process_child_process_spawnsync_command_args_options
773
+ [ `ChildProcess#kill()` ] : #child_process_child_kill_signal
774
+ [ `ChildProcess#send()` ] : #child_process_child_send_message_sendhandle_callback
775
+ [ `Error` ] : errors.html#errors_class_error
776
+ [ `EventEmitter` ] : events.html#events_class_events_eventemitter
777
+ [ `exec()` ] : #child_process_child_process_exec_command_options_callback
778
+ [ `execFile()` ] : #child_process_child_process_execfile_file_args_options_callback
779
+ [ `fork()` ] : #child_process_child_process_fork_modulepath_args_options
780
+ [ `net.Server` ] : net.html#net_class_net_server
781
+ [ `net.Socket` ] : net.html#net_class_net_socket
782
+ [ `spawn()` ] : #child_process_child_process_spawn_command_args_options
783
+ [ `stdio` ] : #child_process_options_stdio
784
+ [ below ] : #child_process_asynchronous_process_creation
785
+ [ synchronous counterparts ] : #child_process_synchronous_process_creation
0 commit comments