Skip to content

Commit bf42cc8

Browse files
TrottFishrock123
authored andcommitted
doc: process exit event is not guaranteed to fire
This change: * notes that the exit event is not guaranteed to fire * provides an example situation where the exit event may not fire * makes a minor copyediting change * enforces 80 character wrap in one place where it was not honored Fixes: nodejs#2853 PR-URL: nodejs#2861 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 079a217 commit bf42cc8

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

doc/api/process.markdown

+13-10
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ finished running the process will exit. Therefore you **must** only perform
5959
checks on the module's state (like for unit tests). The callback takes one
6060
argument, the code the process is exiting with.
6161

62+
This event may not be fired if the process terminates due to signals like
63+
`SIGINT`, `SIGTERM`, `SIGKILL`, and `SIGHUP`.
64+
6265
Example of listening for `exit`:
6366

6467
process.on('exit', function(code) {
@@ -218,7 +221,7 @@ Note:
218221
the terminal mode before exiting with code `128 + signal number`. If one of
219222
these signals has a listener installed, its default behavior will be removed
220223
(Node.js will no longer exit).
221-
- `SIGPIPE` is ignored by default, it can have a listener installed.
224+
- `SIGPIPE` is ignored by default. It can have a listener installed.
222225
- `SIGHUP` is generated on Windows when the console window is closed, and on other
223226
platforms under various similar conditions, see signal(7). It can have a
224227
listener installed, however Node.js will be unconditionally terminated by
@@ -237,13 +240,13 @@ Note:
237240
- `SIGKILL` cannot have a listener installed, it will unconditionally terminate
238241
Node.js on all platforms.
239242
- `SIGSTOP` cannot have a listener installed.
240-
241-
Note that Windows does not support sending Signals, but Node.js offers some
242-
emulation with `process.kill()`, and `child_process.kill()`:
243-
- Sending signal `0` can be used to search for the existence of a process
244243
- Sending `SIGINT`, `SIGTERM`, and `SIGKILL` cause the unconditional exit of the
245244
target process.
246245

246+
Note that Windows does not support sending Signals, but Node.js offers some
247+
emulation with `process.kill()`, and `child_process.kill()`. Sending signal `0`
248+
can be used to test for the existence of a process
249+
247250
## process.stdout
248251

249252
A `Writable Stream` to `stdout` (on fd `1`).
@@ -714,12 +717,12 @@ string describing the signal to send. Signal names are strings like
714717
'SIGINT' or 'SIGHUP'. If omitted, the signal will be 'SIGTERM'.
715718
See [Signal Events](#process_signal_events) and kill(2) for more information.
716719

717-
Will throw an error if target does not exist, and as a special case, a signal of
718-
`0` can be used to test for the existence of a process.
720+
Will throw an error if target does not exist, and as a special case, a signal
721+
of `0` can be used to test for the existence of a process.
719722

720-
Note that just because the name of this function is `process.kill`, it is
721-
really just a signal sender, like the `kill` system call. The signal sent
722-
may do something other than kill the target process.
723+
Note that even though the name of this function is `process.kill`, it is really
724+
just a signal sender, like the `kill` system call. The signal sent may do
725+
something other than kill the target process.
723726

724727
Example of sending a signal to yourself:
725728

0 commit comments

Comments
 (0)