diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2009-09-28 18:50:19 +0400 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2009-09-28 20:48:18 +0400 |
commit | 23c7f472d066087d8053e31e3797a91053a79d9a (patch) | |
tree | bed49cae3b2d4efa366fc0e035cd982eca3ce9da /doc/node.1 | |
parent | c27d9f986a01b86d30b11fd20a3dbd43251ec13a (diff) |
API: Move node.exit() to process.exit().
Diffstat (limited to 'doc/node.1')
-rw-r--r-- | doc/node.1 | 83 |
1 files changed, 35 insertions, 48 deletions
diff --git a/doc/node.1 b/doc/node.1 index 1b08915ea2d..836c307d62f 100644 --- a/doc/node.1 +++ b/doc/node.1 @@ -42,41 +42,58 @@ Node supports 3 string encodings\. UTF\-8 ("utf8"), ASCII ("ascii"), and Binary .sp Unless otherwise noted, functions are all asynchronous and do not block execution\. .sp -.SS "Helpers and Global Variables" +.SS "Helpers" These objects are available to all programs\. .PP -node\.exit(code) -.RS 4 -Immediately ends the process with the specified code\. -.RE -.PP node\.cwd() .RS 4 Returns the current working directory of the process\. .RE .PP -ARGV +__filename .RS 4 -An array containing the command line arguments\. +The filename of the script being executed\. .RE +.SS "The process Object" +process is the equivalent of window in browser\-side javascript\. It is the global scope\. process is an instance of node\.EventEmitter\. +.sp +.TS +allbox tab(:); +ltB ltB ltBx. +T{ +Event +T}:T{ +Parameters +T}:T{ +Notes +T} +.T& +lt lt lt. +T{ +"exit" +.sp +T}:T{ +code +.sp +T}:T{ +Made when the process exits\. A listener on this event should not try to perform I/O since the process will forcibly exit in less than microsecond\. However, it is a good hook to perform constant time checks of the module\(cqs state (like for unit tests)\. The parameter code is the integer exit code passed to process\.exit()\. +.sp +T} +.TE .PP -ENV +process\.exit(code=0) .RS 4 -An object containing the user environment\. See environ(7)\. +Ends the process with the specified code\. By default it exits with the success code 0\. .RE .PP -__filename +process\.ARGV .RS 4 -The filename of the script being executed\. +An array containing the command line arguments\. .RE .PP -process +process\.ENV .RS 4 -A special global object\. The -process -object is like the -window -object of browser\-side javascript\. +An object containing the user environment\. See environ(7)\. .RE .SS "Utilities" These function are in "/utils\.js"\. Use require("/utils\.js") to access them\. @@ -418,36 +435,6 @@ Node comes with several libraries which are installed when "make install" is run .sp (Functions require_async() and include_async() also exist\.) .sp -.sp -.it 1 an-trap -.nr an-no-space-flag 1 -.nr an-break-flag 1 -.br -process.addListener("exit", function () { }) -.RS -When the program exits a special object called process will emit an "exit" event\. -.sp -The "exit" event cannot perform I/O since the process is going to forcibly exit in less than microsecond\. However, it is a good hook to perform constant time checks of the module\(cqs state\. E\.G\. for unit tests: -.sp -.sp -.RS 4 -.nf -include("asserts\.js"); - -var timer_executed = false; - -setTimeout(function () { - timer_executed = true -}, 1000); - -process\.addListener("exit", function () { - assertTrue(timer_executed); -}); -.fi -.RE -Just to reiterate: the "exit" event, is not the place to close files or shutdown servers\. The process will exit before they get performed\. -.sp -.RE .SS "Timers" .PP setTimeout(callback, delay) |