During daily development, we've all dealt with the frustration of processes that won't release ports. The classic workflow of lsof -i :8080
, copying the PID, then kill -9
becomes repetitive and tedious.
An excellent solution already existed: killport by jkfran, a blazing-fast cross-platform tool written in Rust. I used it for months and it works great. However, for my specific needs on macOS, I wanted something more: integrated monitoring, interactive mode, advanced range management. So I created KillPort Advanced v2.0.
Why Start from jkfran's killport?
Before explaining what I built, it's essential to give credit to jkfran. His killport is:
- Blazing fast: written in Rust, excellent native performance
- Cross-platform: works on macOS, Linux, Windows
- Minimal: does one thing and does it well
- Reliable: used by thousands of developers
Without this project as a benchmark reference, I wouldn't have had solid comparison parameters. My work was to build on top of these standards, adding specific features for more complex workflows.
My Approach: Advanced Shell Script
I chose to write a pure ZSH function for several reasons:
- Zero dependencies: no compilation, no binaries
- Native integration: blends with the macOS terminal
- Easy to modify: just edit a script
- Instant installation: source and go
The challenge was maintaining performance comparable to an optimized Rust binary.
Extended Features
Flexible Management
# Single port
killport 3000
# Multiple ports
killport 3000 4000 8080
# Port range
killport 8000-8010
Interactive Mode
kpi # Alias for --interactive
# Output:
# Listening processes:
# # PORT PROCESS PID
# 1 3000 node 1234
# 2 8080 python3 5678
# Select number (or 'q' to quit):
Integrated Monitoring
ports # List all ports (alias for --list)
netstats # Detailed network statistics (alias for --stats)
Watch Mode
killport --watch 3000
# Continuously monitors and auto-kills
Security
- Protected ports (22, 80, 443, 3306, 5432) with mandatory confirmation
- Dry-run mode (
--dry-run
) - Operation history (
kph
)
The Benchmark: Honest Comparison
I wanted to do a serious comparison with jkfran's killport installed via Homebrew. I created a complete benchmark suite that tests 5 different scenarios with detailed statistics.
Methodology
For each test I calculated:
- Min (ms): minimum time
- Max (ms): maximum time
- Avg (ms): average time
- StdDev (σ): standard deviation (consistency)
Tests performed:
- Kill single port (5 iterations)
- Kill 3 simultaneous ports (5 iterations)
- Kill range of 21 ports (3 iterations)
- List ports - Advanced only
- Network statistics - Advanced only
Detailed Results
TEST 1: Kill Single Port
Tool | Min | Max | Avg | StdDev | Winner |
---|---|---|---|---|---|
killport (brew) | 25ms | 25ms | 25ms | ±0ms | ✅ |
KillPort Advanced | 27ms | 27ms | 27ms | ±0ms |
Difference: brew faster by 2ms (7%)
TEST 2: Kill 3 Simultaneous Ports
Tool | Min | Max | Avg | StdDev | Winner |
---|---|---|---|---|---|
KillPort Advanced | 31ms | 31ms | 31ms | ±0ms | ✅ |
killport (brew) | 32ms | 32ms | 32ms | ±0ms |
Difference: Advanced faster by 1ms (3%)
TEST 3: Range of 21 Ports (9100-9120)
Tool | Min | Max | Avg | StdDev | Result |
---|---|---|---|---|---|
KillPort Advanced | 20ms | 20ms | 20ms | ±0ms | ⚖️ |
killport (brew) | 20ms | 20ms | 20ms | ±0ms | ⚖️ |
Result: Identical performance
TEST 4 & 5: KillPort Advanced Exclusive Features
Feature | Time | Notes |
---|---|---|
--list |
22ms | Lists active ports |
--stats |
22ms | Network statistics |
Interpretation
Performance is virtually identical - we're talking about 2ms differences that are imperceptible in daily practice. The standard deviation of 0 indicates that both tools are extremely consistent and reliable.
According to BENCHMARK_GUIDE parameters:
- ✅ All tests < 30ms = Excellent
- ✅ σ = 0ms = Very consistent
Which One to Choose?
killport (brew) by jkfran - When to use it
✅ You want the bare minimum essentials
✅ You need cross-platform support (Linux, Windows)
✅ You prefer compiled binaries
✅ Pure performance is top priority
Installation: brew install killport
KillPort Advanced v2.0 - When to use it
✅ You work exclusively on macOS
✅ You need integrated monitoring (--list
, --stats
)
✅ You want interactive mode and watch mode
✅ You prefer easily modifiable shell scripts
✅ You need protections for critical ports
Installation:
git clone https://github.com/AntonioDEM/killport-advanced.git
cd killport-advanced
bash install_killport.sh
source ~/.zshrc
Simplified Installation
The automatic installer:
- Finds source files
- Configures everything automatically
- Creates convenient aliases (
kp
,kpi
,ports
,netstats
,kph
) - Includes uninstaller (
killport-uninstall
)
Practical Examples
Web Development
# Express server stuck
killport 3000
# Multiple services
killport 3000 4000 8080
# Complete environment cleanup
killport 3000-3010
Debugging
# What's occupying ports?
ports
# Who's using most connections?
netstats
Automation
# Continuous auto-kill
killport --watch 3000 &
Reproducible Benchmarks
I included the complete suite to allow anyone to verify the results:
cd killport-advanced/benchmark
# Run benchmark
./benchmark_original.sh
# Visualize with ASCII charts
./benchmark_visualizer_original.sh
Generated outputs:
-
benchmark_results_TIMESTAMP.txt
- Detailed report -
benchmark_results_TIMESTAMP.csv
- Data for analysis -
benchmark_charts_TIMESTAMP.txt
- ASCII charts (export) -
benchmark_report_TIMESTAMP.md
- Markdown report (export)
Complete guide: BENCHMARK_GUIDE.md
Results Transparency
I chose to publish all results, including those where jkfran's killport is faster. Honesty is fundamental: I'm not trying to "beat" the original project, but to offer an alternative with different features for different needs.
The 2ms difference in TEST 1 is negligible and probably related to the overhead of a shell function vs a compiled binary. But I gain monitoring, interactivity, and flexibility.
What I Learned
This project taught me:
- Serious benchmarking: how to test correctly and honestly
- Advanced shell scripting: complex argument and state management
- Performance tuning: optimizing scripts to compete with binaries
- Documentation: the importance of clear guides and examples
Credits and Acknowledgments
- jkfran for original killport - fundamental as reference
- The open source community for feedback and support
- All project contributors
Useful Links
- KillPort Advanced Repository: github.com/AntonioDEM/killport-advanced
- Original killport Repository: github.com/jkfran/killport
- Complete Benchmark Report: benchmark_report_20251005_214913.md
- Benchmark Guide: BENCHMARK_GUIDE.md
- Detailed Comparison: Confronto_con_brew.md
Conclusions
KillPort Advanced v2.0 doesn't want to replace jkfran's killport - that would be presumptuous. It's a macOS-specific evolution that adds advanced features while maintaining comparable performance.
If you're looking for a cross-platform, fast, and minimal tool, use jkfran's killport.
If you work on macOS and want monitoring, interactivity, and protections, try KillPort Advanced.
Both are open source, both work great.
If you find this project useful, leave a star on GitHub. And if you have suggestions or bugs, PRs are welcome.
Top comments (0)