Kill Process Button
psys provides a convenient way to terminate processes directly from the listeners table. Each row in the table includes an Actions column with a trash icon button that allows you to kill the process.How It Works
When you click the kill button, psys:- Sends a POST request to
/api/connections/killwith the process ID - The API validates the PID and attempts to terminate the process
- Automatically refreshes the connections data to reflect the change
The Kill API Endpoint
The API endpoint handles the termination request with proper validation and error handling:SIGTERM Signal
psys uses SIGTERM (signal 15) to terminate processes. This signal:- Allows the process to perform cleanup operations
- Closes open files and network connections gracefully
- Triggers shutdown hooks and handlers
- Is the standard way to request process termination
SIGTERM is not a forceful kill. If a process doesn’t respond to SIGTERM, you may need to use
kill -9 (SIGKILL) from the command line.Permission Requirements
On Linux, you can only send signals to processes that you own. This means:What processes can I kill?
What processes can I kill?
- Processes running under your user account
- Processes started by you
- Not system processes owned by root (unless you run psys as root)
- Not processes owned by other users
What happens if I don't have permission?
What happens if I don't have permission?
The API will return a 403 Forbidden error with the message “Permission denied”. This is handled by catching the
EPERM error code from Node.js.Error Handling
psys provides specific error messages for different failure scenarios:ESRCH - Process Not Found
HTTP 404: The process with the specified PID does not exist. This can happen if:- The process already terminated
- You specified an invalid PID
- The process ended between when you viewed the table and clicked kill
EPERM - Permission Denied
HTTP 403: You don’t have permission to kill this process. Reasons include:- The process is owned by another user
- The process is a system process (owned by root)
- SELinux or AppArmor policies prevent the operation
Invalid PID
HTTP 400: The provided PID is not valid (not a positive integer).Other Errors
HTTP 500: Any other unexpected error, with the error message included in the response.UI Feedback
The kill button provides visual feedback during the operation:components/connections-dashboard.tsx:354
Best Practices
Use SIGTERM First
Always try SIGTERM (the psys kill button) before resorting to SIGKILL from the command line.
Check Connections
Before killing a process, review its connections in the “Connect to” column to understand its dependencies.
Verify PID
If you’re unsure about a process, check the full command in the PID column tooltip before terminating it.
Permission Awareness
Remember you can only kill your own processes. Run psys with appropriate privileges if needed.