Variables
argv:Array<String>
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.
E.g:
$ node process-2.js one two=three four
0: node
1: /Users/mjr/work/node/process-2.js
2: one
3: two=three
4: four
config:Dynamic<Dynamic>
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.
execArgv:Array<String>
This is the set of node-specific command line options from the executable that started the process.
These options do not show up in 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.
exitCode:Null<Int>
A number which will be the process exit code, when the process either exits gracefully,
or is exited via process.exit()
without specifying a code.
Specifying a code to process.exit(code)
will override any previous setting of process.exitCode
.
read onlymainModule:Module
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.
stderr:IWritable
A writable stream to stderr.
stderr
and stdout
are unlike other streams in Node in that writes to them are usually blocking.
stdout:IWritable
A Writable Stream to stdout.
stderr
and stdout
are unlike other streams in Node in that writes to them are usually blocking.
Methods
abort():Void
This causes node to emit an abort. This will cause node to exit and generate a core file.
chdir(directory:String):Void
Changes the current working directory of the process or throws an exception if that fails.
disconnect():Void
Close the IPC channel to parent process.
Only available for child processes. See ChildProcess.disconnect
.
exit(?code:Int):Void
Ends the process with the specified code
. If the code
is omitted, exit uses either the
'success' code 0
or the value of process.exitCode
if specified.
getgid():Int
Gets the group identity of the process. See getgid(2). Note: this function is only available on POSIX platforms (i.e. not Windows)
getgroups():Array<Int>
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. Note: this function is only available on POSIX platforms (i.e. not Windows)
getuid():Int
Gets the user identity of the process. See getuid(2). Note: this function is only available on POSIX platforms (i.e. not Windows)
hrtime():Array<Float>
hrtime(prev:Array<Float>):Array<Float>
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 hrtime
to get a diff reading,
useful for benchmarks and measuring intervals
initgroups(user:EitherType<String, Int>, extra_group:EitherType<String, Int>):Void
Reads /etc/group and initializes the group access list, using all groups of which the user is a member. This is a privileged operation, meaning you need to be root or have the CAP_SETGID capability.
Note: this function is only available on POSIX platforms (i.e. not Windows)
kill(pid:Int, ?signal:String):Void
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 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.
memoryUsage():MemoryUsage
Returns an object describing the memory usage of the Node process measured in bytes.
nextTick(callback:() ‑> Void, args:Rest<Dynamic>):Void
On the next loop around the event loop call this callback. This is not a simple alias to setTimeout(fn, 0), it's much more efficient. It typically runs before any other I/O events fire, but there are some exceptions.
This is important in developing APIs where you want to give the user the chance to assign event handlers after an object has been constructed, but before any I/O has occurred.
send(message:Dynamic, ?callback:Error ‑> Void):Bool
send(message:Dynamic, sendHandle:Dynamic, options:ChildProcessSendOptions, ?callback:Error ‑> Void):Bool
send(message:Dynamic, sendHandle:Dynamic, ?callback:Error ‑> Void):Bool
Send a message to the parent process.
Only available for child processes. See ChildProcess.send
.
setgid(id:Int):Void
setgid(id:String):Void
Sets the group identity of the process. See setgid(2). This accepts either a numerical ID or a groupname string. If a groupname is specified, this method blocks while resolving it to a numerical ID.
Note: this function is only available on POSIX platforms (i.e. not Windows)
setgroups(groups:Array<EitherType<String, Int>>):Void
Sets the supplementary group IDs. This is a privileged operation, meaning you need to be root or have the CAP_SETGID capability.
Note: this function is only available on POSIX platforms (i.e. not Windows) The list can contain group IDs, group names or both.
setuid(id:Int):Void
setuid(id:String):Void
Sets the user identity of the process. See setuid(2). This accepts either a numerical ID or a username string. If a username is specified, this method blocks while resolving it to a numerical ID.
Note: this function is only available on POSIX platforms (i.e. not Windows)