Kill all processes in the process tree, including the root process.\hypertarget{md_sfcode_node_modules_tree_kill_README_autotoc_md30633}{}\doxysection{Examples}\label{md_sfcode_node_modules_tree_kill_README_autotoc_md30633}
Kill all the descendent processes of the process with pid {\ttfamily 1}, including the process with pid {\ttfamily 1} itself\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{var kill = require('tree-\/kill');}
\DoxyCodeLine{kill(1); }

\end{DoxyCode}


Send a signal other than SIGTERM.\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{var kill = require('tree-\/kill');}
\DoxyCodeLine{kill(1, 'SIGKILL'); }

\end{DoxyCode}


Run a callback when done killing the processes. Passes an error argument if there was an error. 
\begin{DoxyCode}{0}
\DoxyCodeLine{var kill = require('tree-\/kill');}
\DoxyCodeLine{kill(1, 'SIGKILL', function(err) \{}
\DoxyCodeLine{    // Do things}
\DoxyCodeLine{\}); }

\end{DoxyCode}


You can also install tree-\/kill globally and use it as a command\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{tree-\/kill 1          \# sends SIGTERM to process 1 and its descendents}
\DoxyCodeLine{tree-\/kill 1 SIGTERM  \# same}
\DoxyCodeLine{tree-\/kill 1 SIGKILL  \# sends KILL instead of TERMINATE }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_tree_kill_README_autotoc_md30634}{}\doxysection{Methods}\label{md_sfcode_node_modules_tree_kill_README_autotoc_md30634}
\hypertarget{md_sfcode_node_modules_tree_kill_README_autotoc_md30635}{}\doxysubsection{require(\textquotesingle{}tree-\/kill\textquotesingle{})(pid, \mbox{[}signal\mbox{]}, \mbox{[}callback\mbox{]});}\label{md_sfcode_node_modules_tree_kill_README_autotoc_md30635}
Sends signal {\ttfamily signal} to all children processes of the process with pid {\ttfamily pid}, including {\ttfamily pid}. Signal defaults to {\ttfamily SIGTERM}.

For Linux, this uses {\ttfamily ps -\/o pid -\/-\/no-\/headers -\/-\/ppid PID} to find the parent pids of {\ttfamily PID}.

For Darwin/\+OSX, this uses {\ttfamily pgrep -\/P PID} to find the parent pids of {\ttfamily PID}.

For Windows, this uses `\textquotesingle{}taskkill /pid PID /T /F'\`{} to kill the process tree. Note that on Windows, sending the different kinds of POSIX signals is not possible.\hypertarget{md_sfcode_node_modules_tree_kill_README_autotoc_md30636}{}\doxysection{Install}\label{md_sfcode_node_modules_tree_kill_README_autotoc_md30636}
With \href{https://npmjs.org}{\texttt{ npm}} do\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{npm install tree-\/kill }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_tree_kill_README_autotoc_md30637}{}\doxysection{License}\label{md_sfcode_node_modules_tree_kill_README_autotoc_md30637}
MIT\hypertarget{md_sfcode_node_modules_tree_kill_README_autotoc_md30638}{}\doxysection{Changelog}\label{md_sfcode_node_modules_tree_kill_README_autotoc_md30638}
\hypertarget{md_sfcode_node_modules_tree_kill_README_autotoc_md30639}{}\doxysubsection{\mbox{[}1.\+2.\+2\mbox{]} -\/ 2019-\/12-\/11}\label{md_sfcode_node_modules_tree_kill_README_autotoc_md30639}
\hypertarget{md_sfcode_node_modules_tree_kill_README_autotoc_md30640}{}\doxysubsubsection{Changed}\label{md_sfcode_node_modules_tree_kill_README_autotoc_md30640}

\begin{DoxyItemize}
\item security fix\+: sanitize {\ttfamily pid} parameter to fix arbitrary code execution vulnerability
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_tree_kill_README_autotoc_md30641}{}\doxysubsection{\mbox{[}1.\+2.\+1\mbox{]} -\/ 2018-\/11-\/05}\label{md_sfcode_node_modules_tree_kill_README_autotoc_md30641}
\hypertarget{md_sfcode_node_modules_tree_kill_README_autotoc_md30642}{}\doxysubsubsection{Changed}\label{md_sfcode_node_modules_tree_kill_README_autotoc_md30642}

\begin{DoxyItemize}
\item added missing LICENSE file
\item updated Type\+Script definitions
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_tree_kill_README_autotoc_md30643}{}\doxysubsection{\mbox{[}1.\+2.\+0\mbox{]} -\/ 2017-\/09-\/19}\label{md_sfcode_node_modules_tree_kill_README_autotoc_md30643}
\hypertarget{md_sfcode_node_modules_tree_kill_README_autotoc_md30644}{}\doxysubsubsection{Added}\label{md_sfcode_node_modules_tree_kill_README_autotoc_md30644}

\begin{DoxyItemize}
\item Type\+Script definitions 
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_tree_kill_README_autotoc_md30645}{}\doxysubsubsection{Changed}\label{md_sfcode_node_modules_tree_kill_README_autotoc_md30645}

\begin{DoxyItemize}
\item {\ttfamily kill(pid, callback)} works. Before you had to use {\ttfamily kill(pid, signal, callback)}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_tree_kill_README_autotoc_md30646}{}\doxysubsection{\mbox{[}1.\+1.\+0\mbox{]} -\/ 2016-\/05-\/13}\label{md_sfcode_node_modules_tree_kill_README_autotoc_md30646}
\hypertarget{md_sfcode_node_modules_tree_kill_README_autotoc_md30647}{}\doxysubsubsection{Added}\label{md_sfcode_node_modules_tree_kill_README_autotoc_md30647}

\begin{DoxyItemize}
\item A {\ttfamily tree-\/kill} CLI
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_tree_kill_README_autotoc_md30648}{}\doxysubsection{\mbox{[}1.\+0.\+0\mbox{]} -\/ 2015-\/09-\/17}\label{md_sfcode_node_modules_tree_kill_README_autotoc_md30648}
\hypertarget{md_sfcode_node_modules_tree_kill_README_autotoc_md30649}{}\doxysubsubsection{Added}\label{md_sfcode_node_modules_tree_kill_README_autotoc_md30649}

\begin{DoxyItemize}
\item optional callback
\item Darwin support 
\end{DoxyItemize}