@idirdev/killport
v1.0.0
Published
Find and kill processes on a TCP port
Downloads
35
Readme
killport
[EN] Find and kill processes occupying a given port. [FR] Trouver et terminer les processus occupant un port donne.
Features / Fonctionnalites
[EN]
- Detect which PID is listening on a TCP port
- Kill processes gracefully (SIGTERM) or forcefully (SIGKILL / taskkill /F)
- Dry-run mode to preview without killing
- Cross-platform: Linux, macOS, Windows
[FR]
- Detecter quel PID ecoute sur un port TCP
- Terminer les processus en douceur (SIGTERM) ou de force (SIGKILL / taskkill /F)
- Mode dry-run pour previsualiser sans tuer
- Multi-plateforme : Linux, macOS, Windows
Installation
npm install -g @idirdev/killportCLI Usage / Utilisation CLI
# Kill process on port 3000
killport 3000
# Force kill
killport 3000 --force
# Dry run (show PID only)
killport 3000 --dry-run
# Help
killport --helpExample Output / Exemple de sortie
$ killport 3000
PID 12345: killed
$ killport 8080 --dry-run
PID 54321
$ killport 9999
No process on port 9999API (Programmatic) / API (Programmation)
const { findProcessOnPort, killPort } = require('killport');
// Find processes on port 3000
const procs = findProcessOnPort(3000);
// => [{ pid: 12345, port: 3000 }]
// Kill all processes on port 3000
const result = killPort(3000, { force: true });
// => { port: 3000, killed: [{ pid: 12345, killed: true }], notFound: false }API Reference
| Function | Description EN | Description FR |
|---|---|---|
| findProcessOnPort(port) | Returns array of PIDs on a port | Retourne les PIDs sur un port |
| killProcess(pid, force) | Kill a process by PID | Termine un processus par PID |
| killPort(port, opts) | Kill all processes on a port | Termine tous les processus sur un port |
License
MIT - idirdev
