A replacement for process.\+exit that ensures stdio are fully drained before exiting.

To make a long story short, if {\ttfamily process.\+exit} is called on Windows, script output is often truncated when pipe-\/redirecting {\ttfamily stdout} or {\ttfamily stderr}. This module attempts to work around this issue by waiting until those streams have been completely drained before actually calling {\ttfamily process.\+exit}.

See \href{https://github.com/joyent/node/issues/3584}{\texttt{ Node.\+js issue \#3584}} for further reference.

Tested in OS X 10.\+8, Windows 7 on Node.\+js 0.\+8.\+25 and 0.\+10.\+18.

Based on some code by \href{https://github.com/vladikoff}{\texttt{ @vladikoff}}.\hypertarget{md_sfcode_node_modules_exit_README_autotoc_md9399}{}\doxysection{Getting Started}\label{md_sfcode_node_modules_exit_README_autotoc_md9399}
Install the module with\+: {\ttfamily npm install exit}


\begin{DoxyCode}{0}
\DoxyCodeLine{var exit = require('exit');}
\DoxyCodeLine{}
\DoxyCodeLine{// These lines should appear in the output, EVEN ON WINDOWS.}
\DoxyCodeLine{console.log("{}omg"{});}
\DoxyCodeLine{console.error("{}yay"{});}
\DoxyCodeLine{}
\DoxyCodeLine{// process.exit(5);}
\DoxyCodeLine{exit(5);}
\DoxyCodeLine{}
\DoxyCodeLine{// These lines shouldn't appear in the output.}
\DoxyCodeLine{console.log("{}wtf"{});}
\DoxyCodeLine{console.error("{}bro"{}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_exit_README_autotoc_md9400}{}\doxysection{Don\textquotesingle{}t believe me? Try it for yourself.}\label{md_sfcode_node_modules_exit_README_autotoc_md9400}
In Windows, clone the repo and cd to the {\ttfamily test\textbackslash{}fixtures} directory. The only difference between \href{test/fixtures/log.js}{\texttt{ log.\+js}} and \href{test/fixtures/log-broken.js}{\texttt{ log-\/broken.\+js}} is that the former uses {\ttfamily exit} while the latter calls {\ttfamily process.\+exit} directly.

This test was done using cmd.\+exe, but you can see the same results using {\ttfamily $\vert$ grep \char`\"{}std\char`\"{}} in either Power\+Shell or git-\/bash.


\begin{DoxyCode}{0}
\DoxyCodeLine{C:\(\backslash\)node-\/exit\(\backslash\)test\(\backslash\)fixtures>node log.js 0 10 stdout stderr 2>\&1 | find "{}std"{}}
\DoxyCodeLine{stdout 0}
\DoxyCodeLine{stderr 0}
\DoxyCodeLine{stdout 1}
\DoxyCodeLine{stderr 1}
\DoxyCodeLine{stdout 2}
\DoxyCodeLine{stderr 2}
\DoxyCodeLine{stdout 3}
\DoxyCodeLine{stderr 3}
\DoxyCodeLine{stdout 4}
\DoxyCodeLine{stderr 4}
\DoxyCodeLine{stdout 5}
\DoxyCodeLine{stderr 5}
\DoxyCodeLine{stdout 6}
\DoxyCodeLine{stderr 6}
\DoxyCodeLine{stdout 7}
\DoxyCodeLine{stderr 7}
\DoxyCodeLine{stdout 8}
\DoxyCodeLine{stderr 8}
\DoxyCodeLine{stdout 9}
\DoxyCodeLine{stderr 9}
\DoxyCodeLine{}
\DoxyCodeLine{C:\(\backslash\)node-\/exit\(\backslash\)test\(\backslash\)fixtures>node log-\/broken.js 0 10 stdout stderr 2>\&1 | find "{}std"{}}
\DoxyCodeLine{}
\DoxyCodeLine{C:\(\backslash\)node-\/exit\(\backslash\)test\(\backslash\)fixtures> }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_exit_README_autotoc_md9401}{}\doxysection{Contributing}\label{md_sfcode_node_modules_exit_README_autotoc_md9401}
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using \href{http://gruntjs.com/}{\texttt{ Grunt}}.\hypertarget{md_sfcode_node_modules_exit_README_autotoc_md9402}{}\doxysection{Release History}\label{md_sfcode_node_modules_exit_README_autotoc_md9402}
2013-\/11-\/26 -\/ v0.\+1.\+2 -\/ Fixed a bug with hanging processes. ~\newline
 2013-\/09-\/26 -\/ v0.\+1.\+1 -\/ Fixed some bugs. It seems to actually work now! ~\newline
 2013-\/09-\/20 -\/ v0.\+1.\+0 -\/ Initial release.\hypertarget{md_sfcode_node_modules_exit_README_autotoc_md9403}{}\doxysection{License}\label{md_sfcode_node_modules_exit_README_autotoc_md9403}
Copyright (c) 2013 \char`\"{}\+Cowboy\char`\"{} Ben Alman ~\newline
 Licensed under the MIT license. 