What is fkill?
The fkill npm package is a utility for forcefully killing processes. It provides a simple and user-friendly way to terminate processes by their name, port, or PID (Process ID).
What are fkill's main functionalities?
Kill a process by name
This feature allows you to kill a process by specifying its name. In this example, the 'chrome' process is terminated.
const fkill = require('fkill');
fkill('chrome').then(() => {
console.log('Chrome has been killed');
});
Kill a process by PID
This feature allows you to kill a process by specifying its PID. In this example, the process with PID 1337 is terminated.
const fkill = require('fkill');
fkill(1337).then(() => {
console.log('Process with PID 1337 has been killed');
});
Kill a process by port
This feature allows you to kill a process by specifying the port it is using. In this example, the process running on port 8080 is terminated.
const fkill = require('fkill');
fkill(':8080').then(() => {
console.log('Process running on port 8080 has been killed');
});
Force kill a process
This feature allows you to forcefully kill a process. In this example, the 'node' process is forcefully terminated.
const fkill = require('fkill');
fkill('node', {force: true}).then(() => {
console.log('Node process has been forcefully killed');
});
Other packages similar to fkill
taskkill
The taskkill package provides similar functionality to fkill, allowing you to kill processes by name or PID. It is more Windows-centric and uses the Windows taskkill command under the hood.
ps-node
The ps-node package allows you to search for and kill processes by name or PID. It provides more detailed process information and is cross-platform, but it requires more configuration compared to fkill.
kill-port
The kill-port package is focused on killing processes by port. It is simpler and more specialized compared to fkill, which offers a broader range of process-killing options.
Fabulously kill processes. Cross-platform.
Works on macOS (10.13 or later), Linux, Windows.
Install
$ npm install fkill
Usage
const fkill = require('fkill');
(async () => {
await fkill(1337);
console.log('Killed process');
})();
fkill('Safari');
fkill(':8080');
fkill([1337, 'Safari', ':8080']);
API
fkill(input, options?)
Returns a promise that resolves when the processes are killed.
input
Type: number | string | Array<number | string>
One or more process IDs/names/ports to kill.
To kill a port, prefix it with a colon. For example: :8080
.
options
Type: object
force
Type: boolean
Default: false
Force kill the processes.
forceAfterTimeout
Type: number
Default: undefined
Force kill processes that did not exit within the given number of milliseconds.
tree
Type: boolean
Default: true
Kill all child processes along with the parent process. (Windows only)
ignoreCase
Type: boolean
Default: false
Ignore capitalization when killing a process.
Note that the case is always ignored on Windows.
silent
Type: boolean
Default: false
Suppress all error messages. For example: Process doesn't exist
.
Related