kill
In this page:
kill
kill sends a signal to a process, most commonly SIGTERM (the default) to ask it to terminate gracefully, or SIGKILL (kill -9) to force it to stop immediately. You target a process by its PID. Scripts use kill to stop background jobs they started, such as a server process spun up for testing.
Warning: kill -9 (SIGKILL) cannot be caught or ignored by the process, so it never gets a chance to clean up before exiting.
Example: kill
#!/bin/bash
sleep 30 &
pid=$!
echo "Started process $pid"
kill "$pid"
echo "Sent termination signal to $pid"
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 12 topics to unlock
0/12 topics done
Complete these topics first: