
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
The tree-kill npm package is used to kill all processes in the process tree, including the root process. It is particularly useful when you need to clean up all child processes spawned by a parent process, ensuring that no orphan processes remain running.
Kill process trees on different platforms
This code kills the process tree with the PID 12345 on both Windows and Unix systems.
const treeKill = require('tree-kill');
treeKill(12345);
Kill process trees with a specific signal
This code sends the SIGKILL signal to the process tree with the PID 12345, forcing it to terminate immediately.
const treeKill = require('tree-kill');
treeKill(12345, 'SIGKILL');
Kill process trees with a callback
This code attempts to terminate the process tree with the PID 12345 using the SIGTERM signal and provides a callback to handle the result.
const treeKill = require('tree-kill');
treeKill(12345, 'SIGTERM', function(err) {
if (err) {
console.error('Error:', err);
} else {
console.log('Process tree terminated successfully.');
}
});
The ps-tree package is similar to tree-kill in that it allows you to list all child processes of a given PID. However, it does not provide a built-in method to kill these processes; you would need to implement that functionality yourself.
fkill is a more feature-rich process killer that can kill processes by name, port, and more. It also supports killing processes across platforms but does not specifically target the entire process tree like tree-kill does.
pidtree is another package that can list child processes of a given PID. Similar to ps-tree, it does not have the capability to kill the processes, which is the main feature of tree-kill.
Kill all processes in the process tree, including the root process.
Kill all the descendent processes of the process with pid 1
, including the process with pid 1
itself:
var kill = require('tree-kill');
kill(1);
Send a signal other than SIGTERM.:
var kill = require('tree-kill');
kill(1, 'SIGKILL');
Run a callback when done killing the processes. Passes an error argument if there was an error.
var kill = require('tree-kill');
kill(1, 'SIGKILL', function(err) {
// Do things
});
You can also install tree-kill globally and use it as a command:
tree-kill 1 # sends SIGTERM to process 1 and its descendents
tree-kill 1 SIGTERM # same
tree-kill 1 SIGKILL # sends KILL instead of TERMINATE
Sends signal signal
to all children processes of the process with pid pid
, including pid
. Signal defaults to SIGTERM
.
For Linux, this uses ps -o pid --no-headers --ppid PID
to find the parent pids of PID
.
For Darwin/OSX, this uses pgrep -P PID
to find the parent pids of PID
.
For Windows, this uses 'taskkill /pid PID /T /F'
to kill the process tree. Note that on Windows, sending the different kinds of POSIX signals is not possible.
With npm do:
npm install tree-kill
MIT
pid
parameter to fix arbitrary code execution vulnerabilitykill(pid, callback)
works. Before you had to use kill(pid, signal, callback)
tree-kill
CLIFAQs
kill trees of processes
The npm package tree-kill receives a total of 14,606,531 weekly downloads. As such, tree-kill popularity was classified as popular.
We found that tree-kill demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.