\href{https://travis-ci.org/tapjs/signal-exit}{\texttt{ }} \href{https://coveralls.io/r/tapjs/signal-exit?branch=master}{\texttt{ }} \href{https://www.npmjs.com/package/signal-exit}{\texttt{ }} \href{https://github.com/conventional-changelog/standard-version}{\texttt{ }}

When you want to fire an event no matter how a process exits\+:


\begin{DoxyItemize}
\item reaching the end of execution.
\item explicitly having {\ttfamily process.\+exit(code)} called.
\item having {\ttfamily process.\+kill(pid, sig)} called.
\item receiving a fatal signal from outside the process
\end{DoxyItemize}

Use {\ttfamily signal-\/exit}.


\begin{DoxyCode}{0}
\DoxyCodeLine{var onExit = require('signal-\/exit')}
\DoxyCodeLine{}
\DoxyCodeLine{onExit(function (code, signal) \{}
\DoxyCodeLine{  console.log('process exited!')}
\DoxyCodeLine{\}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_signal_exit_README_autotoc_md27022}{}\doxysection{API}\label{md_sfcode_node_modules_signal_exit_README_autotoc_md27022}
{\ttfamily var remove = on\+Exit(function (code, signal) \{\}, options)}

The return value of the function is a function that will remove the handler.

Note that the function {\itshape only} fires for signals if the signal would cause the proces to exit. That is, there are no other listeners, and it is a fatal signal.\hypertarget{md_sfcode_node_modules_signal_exit_README_autotoc_md27023}{}\doxysection{Options}\label{md_sfcode_node_modules_signal_exit_README_autotoc_md27023}

\begin{DoxyItemize}
\item {\ttfamily always\+Last}\+: Run this handler after any other signal or exit handlers. This causes {\ttfamily process.\+emit} to be monkeypatched. 
\end{DoxyItemize}