X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=doc%2Fapi%2Fprocess.markdown;h=03cd1bd3965ab2e9f291457ea245b20d457bd17e;hb=08c83bb172ca963763ef5f53f113e925926a6d7f;hp=699f2d339b8c88429306df6c930fa8161463ac3b;hpb=bddea032b7f2b0f2854faa18855249286bd99428;p=platform%2Fupstream%2Fnodejs.git diff --git a/doc/api/process.markdown b/doc/api/process.markdown index 699f2d3..03cd1bd 100644 --- a/doc/api/process.markdown +++ b/doc/api/process.markdown @@ -52,18 +52,21 @@ cases: ## Event: 'exit' -Emitted when the process is about to exit. This is a good hook to perform -constant time checks of the module's state (like for unit tests). The main -event loop will no longer be run after the 'exit' callback finishes, so -timers may not be scheduled. +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() { + process.on('exit', function(code) { + // do *NOT* do this setTimeout(function() { console.log('This will not run'); }, 0); - console.log('About to exit.'); + console.log('About to exit with code:', code); }); ## Event: 'uncaughtException'