@@ -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.
@@ -237,7 +237,7 @@ Note that the server is now shared between the parent and child, this means
237
237
that some connections will be handled by the parent and some by the child.
238
238
239
239
For ` dgram ` servers the workflow is exactly the same. Here you listen on
240
- a ` message ` event instead of ` connection ` and use ` server.bind ` instead of
240
+ a ` ' message' ` event instead of ` ' connection' ` and use ` server.bind ` instead of
241
241
` server.listen ` . (Currently only supported on UNIX platforms.)
242
242
243
243
#### Example: sending socket object
@@ -308,7 +308,7 @@ to the same object, or null.
308
308
* {Array}
309
309
310
310
A sparse array of pipes to the child process, corresponding with positions in
311
- the [ stdio] [ ] option to [ spawn] [ ] that have been set to ` 'pipe' ` .
311
+ the [ ` stdio ` ] [ ] option to [ ` spawn() ` ] [ ] that have been set to ` 'pipe' ` .
312
312
Note that streams 0-2 are also available as ChildProcess.stdin,
313
313
ChildProcess.stdout, and ChildProcess.stderr, respectively.
314
314
@@ -392,7 +392,7 @@ Runs a command in a shell and buffers the output.
392
392
});
393
393
394
394
The callback gets the arguments ` (error, stdout, stderr) ` . On success, ` error `
395
- will be ` null ` . On error, ` error ` will be an instance of ` Error ` and ` error.code `
395
+ will be ` null ` . On error, ` error ` will be an instance of [ ` Error ` ] [ ] and ` error.code `
396
396
will be the exit code of the child process, and ` error.signal ` will be set to the
397
397
signal that terminated the process.
398
398
@@ -452,7 +452,7 @@ leaner than [`child_process.exec()`][]. It has the same options.
452
452
(Default: ` process.execArgv ` )
453
453
* ` silent ` {Boolean} If true, stdin, stdout, and stderr of the child will be
454
454
piped to the parent, otherwise they will be inherited from the parent, see
455
- the " pipe" and " inherit" options for ` spawn() ` 's ` stdio ` for more details
455
+ the ` ' pipe' ` and ` ' inherit' ` options for [ ` spawn() ` ] [ ] 's [ ` stdio ` ] [ ] for more details
456
456
(default is false)
457
457
* ` uid ` {Number} Sets the user identity of the process. (See setuid(2).)
458
458
* ` gid ` {Number} Sets the group identity of the process. (See setgid(2).)
@@ -473,7 +473,7 @@ done with care and by default will talk over the fd represented an
473
473
environmental variable ` NODE_CHANNEL_FD ` on the child process. The input and
474
474
output on this fd is expected to be line delimited JSON objects.
475
475
476
- * Note: Unlike the ` fork() ` POSIX system call, ` child_process.fork() ` does not clone the
476
+ * Note: Unlike the ` fork() ` POSIX system call, [ ` child_process.fork() ` ] [ ] does not clone the
477
477
current process.*
478
478
479
479
### child_process.spawn(command[ , args] [ , options ] )
@@ -614,7 +614,7 @@ As a shorthand, the `stdio` argument may be one of the following strings:
614
614
* ` 'ignore' ` - ` ['ignore', 'ignore', 'ignore'] `
615
615
* ` 'inherit' ` - ` [process.stdin, process.stdout, process.stderr] ` or ` [0,1,2] `
616
616
617
- Otherwise, the 'stdio' option to ` child_process.spawn() ` is an array where each
617
+ Otherwise, the ` 'stdio' ` option to [ ` child_process.spawn() ` ] [ ] is an array where each
618
618
index corresponds to a fd in the child. The value is one of the following:
619
619
620
620
1 . ` 'pipe' ` - Create a pipe between the child process and the parent process.
@@ -698,7 +698,7 @@ the `SIGTERM` signal and doesn't exit, your process will wait until the child
698
698
process has exited.
699
699
700
700
If the process times out, or has a non-zero exit code, this method *** will***
701
- throw. The ` Error ` object will contain the entire result from
701
+ throw. The [ ` Error ` ] [ ] object will contain the entire result from
702
702
[ ` child_process.spawnSync() ` ] [ ]
703
703
704
704
### child_process.execSync(command[ , options] )
@@ -732,7 +732,7 @@ the `SIGTERM` signal and doesn't exit, your process will wait until the child
732
732
process has exited.
733
733
734
734
If the process times out, or has a non-zero exit code, this method *** will***
735
- throw. The ` Error ` object will contain the entire result from
735
+ throw. The [ ` Error ` ] [ ] object will contain the entire result from
736
736
[ ` child_process.spawnSync() ` ] [ ]
737
737
738
738
### child_process.spawnSync(command[ , args] [ , options ] )
@@ -767,16 +767,20 @@ until the process has completely exited. That is to say, if the process handles
767
767
the ` SIGTERM ` signal and doesn't exit, your process will wait until the child
768
768
process has exited.
769
769
770
- [ below ] : #child_process_asynchronous_process_creation
771
- [ synchronous counterparts ] : #child_process_synchronous_process_creation
772
- [ EventEmitter ] : events.html#events_class_events_eventemitter
773
- [ `ChildProcess#kill()` ] : #child_process_child_kill_signal
774
- [ `ChildProcess#send()` ] : #child_process_child_send_message_sendhandle_callback
775
- [ net.Server ] : net.html#net_class_net_server
776
- [ net.Socket ] : net.html#net_class_net_socket
777
- [ `child_process.fork()` ] : #child_process_child_process_fork_modulepath_args_options
778
- [ stdio ] : #child_process_options_stdio
779
- [ spawn ] : #child_process_child_process_spawn_command_args_options
780
770
[ `child_process.exec()` ] : #child_process_child_process_exec_command_options_callback
771
+ [ `child_process.fork()` ] : #child_process_child_process_fork_modulepath_args_options
781
772
[ `child_process.spawn()` ] : #child_process_child_process_spawn_command_args_options
782
773
[ `child_process.spawnSync()` ] : #child_process_child_process_spawnsync_command_args_options
774
+ [ `ChildProcess#kill()` ] : #child_process_child_kill_signal
775
+ [ `ChildProcess#send()` ] : #child_process_child_send_message_sendhandle_callback
776
+ [ `Error` ] : errors.html#errors_class_error
777
+ [ `EventEmitter` ] : events.html#events_class_events_eventemitter
778
+ [ `exec()` ] : #child_process_child_process_exec_command_options_callback
779
+ [ `execFile()` ] : #child_process_child_process_execfile_file_args_options_callback
780
+ [ `fork()` ] : #child_process_child_process_fork_modulepath_args_options
781
+ [ `net.Server` ] : net.html#net_class_net_server
782
+ [ `net.Socket` ] : net.html#net_class_net_socket
783
+ [ `spawn()` ] : #child_process_child_process_spawn_command_args_options
784
+ [ `stdio` ] : #child_process_options_stdio
785
+ [ below ] : #child_process_asynchronous_process_creation
786
+ [ synchronous counterparts ] : #child_process_synchronous_process_creation
0 commit comments