Node will normally exit with a 0 status code when no more async
operations are pending. The following status codes are used in other
cases:

1Uncaught Fatal Exception - There was an uncaught exception,
and it was not handled by a domain or an uncaughtException event
handler.

2 - Unused (reserved by Bash for builtin misuse)

3Internal JavaScript Parse Error - The JavaScript source code
internal in Node's bootstrapping process caused a parse error. This
is extremely rare, and generally can only happen during development
of Node itself.

4Internal JavaScript Evaluation Failure - The JavaScript
source code internal in Node's bootstrapping process failed to
return a function value when evaluated. This is extremely rare, and
generally can only happen during development of Node itself.

5Fatal Error - There was a fatal unrecoverable error in V8.
Typically a message will be printed to stderr with the prefix FATAL
ERROR.

6Non-function Internal Exception Handler - There was an
uncaught exception, but the internal fatal exception handler
function was somehow set to a non-function, and could not be called.

7Internal Exception Handler Run-Time Failure - There was an
uncaught exception, and the internal fatal exception handler
function itself threw an error while attempting to handle it. This
can happen, for example, if a process.on('uncaughtException') or
domain.on('error') handler throws an error.

9 - Invalid Argument - Either an unknown option was specified,
or an option requiring a value was provided without a value.

10Internal JavaScript Run-Time Failure - The JavaScript
source code internal in Node's bootstrapping process threw an error
when the bootstrapping function was called. This is extremely rare,
and generally can only happen during development of Node itself.

12Invalid Debug Argument - The --debug and/or --debug-brk
options were set, but an invalid port number was chosen.

>128Signal Exits - If Node receives a fatal signal such as
SIGKILL or SIGHUP, then its exit code will be 128 plus the
value of the signal code. This is a standard Unix practice, since
exit codes are defined to be 7-bit integers, and signal exits set
the high-order bit, and then contain the value of the signal code.

Emitted when the process is about to exit. There is no way to prevent the
exiting of the event loop at this point, and once all exit listeners have
finished running the process will exit. Therefore you must only perform
synchronous operations in this handler. This is a good hook to perform
checks on the module's state (like for unit tests). The callback takes one
argument, the code the process is exiting with.

Example of listening for exit:

process.on('exit', function(code) {
// do *NOT* do this
setTimeout(function() {
console.log('This will not run');
}, 0);
console.log('About to exit with code:', code);
});

This event is emitted when node empties it's event loop and has nothing else to
schedule. Normally, node exits when there is no work scheduled, but a listener
for 'beforeExit' can make asynchronous calls, and cause node to continue.

'beforeExit' is not emitted for conditions causing explicit termination, such as
process.exit() or uncaught exceptions, and should not be used as an
alternative to the 'exit' event unless the intention is to schedule more work.

Note that uncaughtException is a very crude mechanism for exception
handling.

Don't use it, use domains instead. If you do use it, restart
your application after every unhandled exception!

Do not use it as the node.js equivalent of On Error Resume Next. An
unhandled exception means your application - and by extension node.js itself -
is in an undefined state. Blindly resuming means anything could happen.

Think of resuming as pulling the power cord when you are upgrading your system.
Nine out of ten times nothing happens - but the 10th time, your system is bust.

An easy way to send the SIGINT signal is with Control-C in most terminal
programs.

Note:

SIGUSR1 is reserved by node.js to start the debugger. It's possible to
install a listener but that won't stop the debugger from starting.

SIGTERM and SIGINT have default handlers on non-Windows platforms that resets
the terminal mode before exiting with code 128 + signal number. If one of
these signals has a listener installed, its default behaviour will be removed
(node will no longer exit).

SIGPIPE is ignored by default, it can have a listener installed.

SIGHUP is generated on Windows when the console window is closed, and on other
platforms under various similar conditions, see signal(7). It can have a
listener installed, however node will be unconditionally terminated by Windows
about 10 seconds later. On non-Windows platforms, the default behaviour of
SIGHUP is to terminate node, but once a listener has been installed its
default behaviour will be removed.

SIGTERM is not supported on Windows, it can be listened on.

SIGINT from the terminal is supported on all platforms, and can usually be
generated with CTRL+C (though this may be configurable). It is not generated
when terminal raw mode is enabled.

SIGBREAK is delivered on Windows when CTRL+BREAK is pressed, on non-Windows
platforms it can be listened on, but there is no way to send or generate it.

SIGWINCH is delivered when the console has been resized. On Windows, this will
only happen on write to the console when the cursor is being moved, or when a
readable tty is used in raw mode.

SIGKILL cannot have a listener installed, it will unconditionally terminate
node on all platforms.

SIGSTOP cannot have a listener installed.

Note that Windows does not support sending Signals, but node offers some
emulation with process.kill(), and child_process.kill():
- Sending signal 0 can be used to search for the existence of a process
- Sending SIGINT, SIGTERM, and SIGKILL cause the unconditional exit of the
target process.

As a Stream, process.stdin can also be used in "old" mode that is compatible
with scripts written for node prior v0.10.
For more information see
Stream compatibility.

In "old" Streams mode the stdin stream is paused by default, so one
must call process.stdin.resume() to read from it. Note also that calling
process.stdin.resume() itself would switch stream to "old" mode.

If you are starting a new project you should prefer a more recent "new" Streams
mode over "old" one.

An array containing the command line arguments. The first element will be
'node', the second element will be the name of the JavaScript file. The
next elements will be any additional command line arguments.

This is the set of node-specific command line options from the
executable that started the process. These options do not show up in
process.argv, and do not include the node executable, the name of
the script, or any options following the script name. These options
are useful in order to spawn child processes with the same execution
environment as the parent.

An Object containing the JavaScript representation of the configure options
that were used to compile the current node executable. This is the same as
the "config.gypi" file that was produced when running the ./configure script.

Send a signal to a process. pid is the process id and signal is the
string describing the signal to send. Signal names are strings like
'SIGINT' or 'SIGHUP'. If omitted, the signal will be 'SIGTERM'.
See Signal Events and kill(2) for more information.

Will throw an error if target does not exist, and as a special case, a signal of
0 can be used to test for the existence of a process.

Note that just because the name of this function is process.kill, it is
really just a signal sender, like the kill system call. The signal sent
may do something other than kill the target process.

Note: the nextTick queue is completely drained on each pass of the
event loop before additional I/O is processed. As a result,
recursively setting nextTick callbacks will block any I/O from
happening, just like a while(true); loop.

Returns the current high-resolution real time in a [seconds, nanoseconds]
tuple Array. It is relative to an arbitrary time in the past. It is not
related to the time of day and therefore not subject to clock drift. The
primary use is for measuring performance between intervals.

You may pass in the result of a previous call to process.hrtime() to get
a diff reading, useful for benchmarks and measuring intervals:

Alternate way to retrieve
require.main.
The difference is that if the main module changes at runtime, require.main
might still refer to the original main module in modules that were required
before the change occurred. Generally it's safe to assume that the two refer
to the same module.

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