Browse Source

doc: add `added:` information for process

Most of the information is gleaned from changelogs. The rest is inferred
from git history.

Omitted cpuUsage() since it's not yet in a release.

Also omitted the streams, events and signals, since I didn't really
think it made sense for those.

Ref: https://github.com/nodejs/node/issues/6578
PR-URL: https://github.com/nodejs/node/pull/6589
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Alexander Makarenko <estliberitas@gmail.com>
v6.x
Bryan English 9 years ago
committed by Evan Lucas
parent
commit
58cd11c844
  1. 142
      doc/api/process.md

142
doc/api/process.md

@ -6,6 +6,9 @@ The `process` object is a global object and can be accessed from anywhere.
It is an instance of [`EventEmitter`][]. It is an instance of [`EventEmitter`][].
## Event: 'beforeExit' ## Event: 'beforeExit'
<!-- YAML
added: v0.11.12
-->
This event is emitted when Node.js empties its event loop and has nothing else This event is emitted when Node.js empties its event loop and has nothing else
to schedule. Normally, Node.js exits when there is no work scheduled, but a to schedule. Normally, Node.js exits when there is no work scheduled, but a
@ -17,11 +20,17 @@ 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. alternative to the `'exit'` event unless the intention is to schedule more work.
## Event: 'disconnect' ## Event: 'disconnect'
<!-- YAML
added: v0.7.7
-->
If process is spawned with an IPC channel, `'disconnect'` will be emitted when If process is spawned with an IPC channel, `'disconnect'` will be emitted when
IPC channel is closed. Read more in [child_process `'disconnect'` event][] doc. IPC channel is closed. Read more in [child_process `'disconnect'` event][] doc.
## Event: 'exit' ## Event: 'exit'
<!-- YAML
added: v0.1.7
-->
Emitted when the process is about to exit. There is no way to prevent the 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 exiting of the event loop at this point, and once all `'exit'` listeners have
@ -46,6 +55,9 @@ process.on('exit', (code) => {
``` ```
## Event: 'message' ## Event: 'message'
<!-- YAML
added: v0.5.10
-->
* `message` {Object} a parsed JSON object or primitive value * `message` {Object} a parsed JSON object or primitive value
* `sendHandle` {Handle object} a [`net.Socket`][] or [`net.Server`][] object, or * `sendHandle` {Handle object} a [`net.Socket`][] or [`net.Server`][] object, or
@ -55,6 +67,9 @@ Messages sent by [`ChildProcess.send()`][] are obtained using the `'message'`
event on the child's process object. event on the child's process object.
## Event: 'rejectionHandled' ## Event: 'rejectionHandled'
<!-- YAML
added: v1.4.1
-->
Emitted whenever a Promise was rejected and an error handler was attached to it Emitted whenever a Promise was rejected and an error handler was attached to it
(for example with [`promise.catch()`][]) later than after an event loop turn. This event (for example with [`promise.catch()`][]) later than after an event loop turn. This event
@ -96,6 +111,9 @@ you to clear the map, which in the case of a very buggy program could grow
indefinitely) or upon process exit (more convenient for scripts). indefinitely) or upon process exit (more convenient for scripts).
## Event: 'uncaughtException' ## Event: 'uncaughtException'
<!-- YAML
added: v0.1.18
-->
The `'uncaughtException'` event is emitted when an exception bubbles all the The `'uncaughtException'` event is emitted when an exception bubbles all the
way back to the event loop. By default, Node.js handles such exceptions by way back to the event loop. By default, Node.js handles such exceptions by
@ -141,6 +159,9 @@ down the process. It is not safe to resume normal operation after
`'uncaughtException'`. `'uncaughtException'`.
## Event: 'unhandledRejection' ## Event: 'unhandledRejection'
<!-- YAML
added: v1.4.1
-->
Emitted whenever a `Promise` is rejected and no error handler is attached to Emitted whenever a `Promise` is rejected and no error handler is attached to
the promise within a turn of the event loop. When programming with promises the promise within a turn of the event loop. When programming with promises
@ -192,6 +213,9 @@ this, you can either attach a dummy [`.catch(() => { })`][`promise.catch()`] han
emitted, or you can use the [`'rejectionHandled'`][] event. emitted, or you can use the [`'rejectionHandled'`][] event.
## Event: 'warning' ## Event: 'warning'
<!-- YAML
added: v6.0.0
-->
Emitted whenever Node.js emits a process warning. Emitted whenever Node.js emits a process warning.
@ -408,11 +432,17 @@ can be used to test for the existence of a process. Sending `SIGINT`,
process. process.
## process.abort() ## process.abort()
<!-- YAML
added: v0.7.0
-->
This causes Node.js to emit an abort. This will cause Node.js to exit and This causes Node.js to emit an abort. This will cause Node.js to exit and
generate a core file. generate a core file.
## process.arch ## process.arch
<!-- YAML
added: v0.5.0
-->
What processor architecture you're running on: `'arm'`, `'ia32'`, or `'x64'`. What processor architecture you're running on: `'arm'`, `'ia32'`, or `'x64'`.
@ -421,6 +451,9 @@ console.log('This processor architecture is ' + process.arch);
``` ```
## process.argv ## process.argv
<!-- YAML
added: v0.1.27
-->
An array containing the command line arguments. The first element will be 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 'node', the second element will be the name of the JavaScript file. The
@ -445,6 +478,9 @@ $ node process-2.js one two=three four
``` ```
## process.chdir(directory) ## process.chdir(directory)
<!-- YAML
added: v0.1.17
-->
Changes the current working directory of the process or throws an exception if that fails. Changes the current working directory of the process or throws an exception if that fails.
@ -460,6 +496,9 @@ catch (err) {
``` ```
## process.config ## process.config
<!-- YAML
added: v0.7.7
-->
An Object containing the JavaScript representation of the configure options An Object containing the JavaScript representation of the configure options
that were used to compile the current Node.js executable. This is the same as that were used to compile the current Node.js executable. This is the same as
@ -499,12 +538,16 @@ modules in the ecosystem that are known to extend, modify, or entirely replace
the value of `process.config`.* the value of `process.config`.*
## process.connected ## process.connected
<!-- YAML
added: v0.7.2
-->
* {Boolean} Set to `false` after `process.disconnect()` is called * {Boolean} Set to `false` after `process.disconnect()` is called
If `process.connected` is `false`, it is no longer possible to send messages. If `process.connected` is `false`, it is no longer possible to send messages.
## process.cpuUsage([previousValue]) ## process.cpuUsage([previousValue])
<!-- TODO add YAML block when cpuUsage is in a release -->
Returns the user and system CPU time usage of the current process, in an object Returns the user and system CPU time usage of the current process, in an object
with properties `user` and `system`, whose values are microsecond values with properties `user` and `system`, whose values are microsecond values
@ -528,6 +571,9 @@ console.log(process.cpuUsage(startUsage));
``` ```
## process.cwd() ## process.cwd()
<!-- YAML
added: v0.1.8
-->
Returns the current working directory of the process. Returns the current working directory of the process.
@ -536,6 +582,9 @@ console.log(`Current directory: ${process.cwd()}`);
``` ```
## process.disconnect() ## process.disconnect()
<!-- YAML
added: v0.7.2
-->
Close the IPC channel to the parent process, allowing this child to exit Close the IPC channel to the parent process, allowing this child to exit
gracefully once there are no other connections keeping it alive. gracefully once there are no other connections keeping it alive.
@ -546,6 +595,9 @@ If Node.js was not spawned with an IPC channel, `process.disconnect()` will be
undefined. undefined.
## process.env ## process.env
<!-- YAML
added: v0.1.27
-->
An object containing the user environment. See environ(7). An object containing the user environment. See environ(7).
@ -604,6 +656,9 @@ console.log(process.env.TEST);
``` ```
## process.emitWarning(warning[, name][, ctor]) ## process.emitWarning(warning[, name][, ctor])
<!-- YAML
added: v6.0.0
-->
* `warning` {String | Error} The warning to emit. * `warning` {String | Error} The warning to emit.
* `name` {String} When `warning` is a String, `name` is the name to use * `name` {String} When `warning` is a String, `name` is the name to use
@ -690,6 +745,9 @@ emitMyWarning();
``` ```
## process.execArgv ## process.execArgv
<!-- YAML
added: v0.7.7
-->
This is the set of Node.js-specific command line options from the This is the set of Node.js-specific command line options from the
executable that started the process. These options do not show up in executable that started the process. These options do not show up in
@ -717,6 +775,9 @@ and process.argv:
``` ```
## process.execPath ## process.execPath
<!-- YAML
added: v0.1.100
-->
This is the absolute pathname of the executable that started the process. This is the absolute pathname of the executable that started the process.
@ -728,6 +789,9 @@ Example:
## process.exit([code]) ## process.exit([code])
<!-- YAML
added: v0.1.13
-->
* `code` {Integer} The exit code. Defaults to `0`. * `code` {Integer} The exit code. Defaults to `0`.
@ -789,6 +853,9 @@ throwing an *uncaught* error and allowing the process to terminate accordingly
is safer than calling `process.exit()`. is safer than calling `process.exit()`.
## process.exitCode ## process.exitCode
<!-- YAML
added: v0.11.8
-->
A number which will be the process exit code, when the process either A number which will be the process exit code, when the process either
exits gracefully, or is exited via [`process.exit()`][] without specifying exits gracefully, or is exited via [`process.exit()`][] without specifying
@ -799,6 +866,9 @@ previous setting of `process.exitCode`.
## process.getegid() ## process.getegid()
<!-- YAML
added: v2.0.0
-->
Note: this function is only available on POSIX platforms (i.e. not Windows, Note: this function is only available on POSIX platforms (i.e. not Windows,
Android) Android)
@ -814,6 +884,9 @@ if (process.getegid) {
## process.geteuid() ## process.geteuid()
<!-- YAML
added: v2.0.0
-->
Note: this function is only available on POSIX platforms (i.e. not Windows, Note: this function is only available on POSIX platforms (i.e. not Windows,
Android) Android)
@ -828,6 +901,9 @@ if (process.geteuid) {
``` ```
## process.getgid() ## process.getgid()
<!-- YAML
added: v0.1.31
-->
Note: this function is only available on POSIX platforms (i.e. not Windows, Note: this function is only available on POSIX platforms (i.e. not Windows,
Android) Android)
@ -842,6 +918,9 @@ if (process.getgid) {
``` ```
## process.getgroups() ## process.getgroups()
<!-- YAML
added: v0.9.4
-->
Note: this function is only available on POSIX platforms (i.e. not Windows, Note: this function is only available on POSIX platforms (i.e. not Windows,
Android) Android)
@ -850,6 +929,9 @@ Returns an array with the supplementary group IDs. POSIX leaves it unspecified
if the effective group ID is included but Node.js ensures it always is. if the effective group ID is included but Node.js ensures it always is.
## process.getuid() ## process.getuid()
<!-- YAML
added: v0.1.28
-->
Note: this function is only available on POSIX platforms (i.e. not Windows, Note: this function is only available on POSIX platforms (i.e. not Windows,
Android) Android)
@ -864,6 +946,9 @@ if (process.getuid) {
``` ```
## process.hrtime() ## process.hrtime()
<!-- YAML
added: v0.7.6
-->
Returns the current high-resolution real time in a `[seconds, nanoseconds]` 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 tuple Array. It is relative to an arbitrary time in the past. It is not
@ -888,6 +973,9 @@ setTimeout(() => {
## process.initgroups(user, extra_group) ## process.initgroups(user, extra_group)
<!-- YAML
added: v0.9.4
-->
Note: this function is only available on POSIX platforms (i.e. not Windows, Note: this function is only available on POSIX platforms (i.e. not Windows,
Android) Android)
@ -909,6 +997,9 @@ console.log(process.getgroups()); // [ 27, 30, 46, 1000 ]
``` ```
## process.kill(pid[, signal]) ## process.kill(pid[, signal])
<!-- YAML
added: v0.0.6
-->
Send a signal to a process. `pid` is the process id and `signal` is the 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 string describing the signal to send. Signal names are strings like
@ -942,6 +1033,9 @@ Note: When SIGUSR1 is received by Node.js it starts the debugger, see
[Signal Events][]. [Signal Events][].
## process.mainModule ## process.mainModule
<!-- YAML
added: v0.1.17
-->
Alternate way to retrieve [`require.main`][]. The difference is that if the main 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 changes at runtime, [`require.main`][] might still refer to the original main
@ -951,6 +1045,9 @@ 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. As with [`require.main`][], it will be `undefined` if there was no entry script.
## process.memoryUsage() ## process.memoryUsage()
<!-- YAML
added: v0.1.16
-->
Returns an object describing the memory usage of the Node.js process Returns an object describing the memory usage of the Node.js process
measured in bytes. measured in bytes.
@ -973,6 +1070,9 @@ This will generate:
## process.nextTick(callback[, arg][, ...]) ## process.nextTick(callback[, arg][, ...])
<!-- YAML
added: v0.1.26
-->
* `callback` {Function} * `callback` {Function}
@ -1059,6 +1159,9 @@ recursively setting nextTick callbacks will block any I/O from
happening, just like a `while(true);` loop. happening, just like a `while(true);` loop.
## process.pid ## process.pid
<!-- YAML
added: v0.1.15
-->
The PID of the process. The PID of the process.
@ -1067,6 +1170,9 @@ console.log(`This process is pid ${process.pid}`);
``` ```
## process.platform ## process.platform
<!-- YAML
added: v0.1.16
-->
What platform you're running on: What platform you're running on:
`'darwin'`, `'freebsd'`, `'linux'`, `'sunos'` or `'win32'` `'darwin'`, `'freebsd'`, `'linux'`, `'sunos'` or `'win32'`
@ -1076,6 +1182,9 @@ console.log(`This platform is ${process.platform}`);
``` ```
## process.release ## process.release
<!-- YAML
added: v3.0.0
-->
An Object containing metadata related to the current release, including URLs An Object containing metadata related to the current release, including URLs
for the source tarball and headers-only tarball. for the source tarball and headers-only tarball.
@ -1109,6 +1218,9 @@ In custom builds from non-release versions of the source tree, only the
relied upon to exist. relied upon to exist.
## process.send(message[, sendHandle[, options]][, callback]) ## process.send(message[, sendHandle[, options]][, callback])
<!-- YAML
added: v0.5.9
-->
* `message` {Object} * `message` {Object}
* `sendHandle` {Handle object} * `sendHandle` {Handle object}
@ -1125,6 +1237,9 @@ parent process using `process.send()`. Each will be received as a
If Node.js was not spawned with an IPC channel, `process.send()` will be undefined. If Node.js was not spawned with an IPC channel, `process.send()` will be undefined.
## process.setegid(id) ## process.setegid(id)
<!-- YAML
added: v2.0.0
-->
Note: this function is only available on POSIX platforms (i.e. not Windows, Note: this function is only available on POSIX platforms (i.e. not Windows,
Android) Android)
@ -1147,6 +1262,9 @@ if (process.getegid && process.setegid) {
``` ```
## process.seteuid(id) ## process.seteuid(id)
<!-- YAML
added: v2.0.0
-->
Note: this function is only available on POSIX platforms (i.e. not Windows, Note: this function is only available on POSIX platforms (i.e. not Windows,
Android) Android)
@ -1169,6 +1287,9 @@ if (process.geteuid && process.seteuid) {
``` ```
## process.setgid(id) ## process.setgid(id)
<!-- YAML
added: v0.1.31
-->
Note: this function is only available on POSIX platforms (i.e. not Windows, Note: this function is only available on POSIX platforms (i.e. not Windows,
Android) Android)
@ -1191,6 +1312,9 @@ if (process.getgid && process.setgid) {
``` ```
## process.setgroups(groups) ## process.setgroups(groups)
<!-- YAML
added: v0.9.4
-->
Note: this function is only available on POSIX platforms (i.e. not Windows, Note: this function is only available on POSIX platforms (i.e. not Windows,
Android) Android)
@ -1201,6 +1325,9 @@ need to be root or have the `CAP_SETGID` capability.
The list can contain group IDs, group names or both. The list can contain group IDs, group names or both.
## process.setuid(id) ## process.setuid(id)
<!-- YAML
added: v0.1.28
-->
Note: this function is only available on POSIX platforms (i.e. not Windows, Note: this function is only available on POSIX platforms (i.e. not Windows,
Android) Android)
@ -1300,6 +1427,9 @@ false
See [the tty docs][] for more information. See [the tty docs][] for more information.
## process.title ## process.title
<!-- YAML
added: v0.1.104
-->
Getter/setter to set what is displayed in `ps`. Getter/setter to set what is displayed in `ps`.
@ -1314,6 +1444,9 @@ memory but that was potentially insecure/confusing in some (rather obscure)
cases. cases.
## process.umask([mask]) ## process.umask([mask])
<!-- YAML
added: v0.1.19
-->
Sets or reads the process's file mode creation mask. Child processes inherit Sets or reads the process's file mode creation mask. Child processes inherit
the mask from the parent process. Returns the old mask if `mask` argument is the mask from the parent process. Returns the old mask if `mask` argument is
@ -1329,10 +1462,16 @@ console.log(
## process.uptime() ## process.uptime()
<!-- YAML
added: v0.5.0
-->
Number of seconds Node.js has been running. Number of seconds Node.js has been running.
## process.version ## process.version
<!-- YAML
added: v0.1.3
-->
A compiled-in property that exposes `NODE_VERSION`. A compiled-in property that exposes `NODE_VERSION`.
@ -1341,6 +1480,9 @@ console.log(`Version: ${process.version}`);
``` ```
## process.versions ## process.versions
<!-- YAML
added: v0.2.0
-->
A property exposing version strings of Node.js and its dependencies. A property exposing version strings of Node.js and its dependencies.

Loading…
Cancel
Save