stop
Stop a running job
SYNOPSIS
kill [-s SIGNAL | -SIGNAL_NAME | -SIGNAL_NUMBER] PID...
For stopping a process:
kill -STOP PID...
kill -s STOP PID...
kill -19 PID...
PARAMETERS
PID...
One or more Process IDs (PIDs) of the processes to which the signal will be sent. You can find PIDs using commands like ps or top.
-s SIGNAL
Specifies the signal to send by name or number. For stopping a process, use STOP or its number 19.
-STOP
A shorthand option to specify the SIGSTOP signal. This is equivalent to -s STOP.
-19
A shorthand option to specify the SIGSTOP signal by its numeric value. This is equivalent to -s 19.
DESCRIPTION
kill is a fundamental Unix/Linux command used to send signals to processes. When used with the STOP signal (signal number 19), it instructs the operating system to pause a running process without terminating it. This is distinct from other signals like SIGTERM or SIGKILL, which are used to request or force process termination. A process stopped using SIGSTOP will remain in a suspended state, consuming system resources but not executing any instructions, until it receives a SIGCONT signal (signal number 18), which resumes its execution.
SIGSTOP is primarily used for job control, allowing users to temporarily halt a background process, inspect its state, or make system adjustments before resuming it. Unlike most other signals, SIGSTOP cannot be caught, ignored, or blocked by the target process, making it a reliable way for the kernel to enforce a halt. It is often employed in debugging scenarios or when managing long-running background tasks.
CAVEATS
Permissions: To stop a process, you must either be its owner or have root privileges. Insufficient permissions will result in an 'Operation not permitted' error.
Unblockable Signal: SIGSTOP is a unique signal in that it cannot be caught, ignored, or blocked by the target process. This ensures that the operating system can always halt a process, regardless of its state or programming.
Terminal Job Control: While kill -STOP can be used for any process, the SIGTSTP signal (usually triggered by Ctrl+Z) is sent to the foreground process group of a terminal to stop it. This is part of shell job control and works similarly to SIGSTOP but is initiated differently.
RESUMING A STOPPED PROCESS
After a process has been stopped using SIGSTOP, it can be resumed by sending it the SIGCONT signal (signal number 18). This is typically done using the command: kill -CONT PID...
or kill -s CONT PID...
. The process will then continue execution from where it left off.
DISTINCTION FROM TERMINATION SIGNALS
It's crucial to understand that SIGSTOP does not terminate a process. It merely pauses it. To terminate a process, other signals like SIGTERM (default for kill, allows graceful shutdown) or SIGKILL (forces immediate termination) are used. A stopped process consumes memory and other resources but no CPU cycles.
HISTORY
The kill command and the concept of signals have been fundamental to Unix-like operating systems since their early development. Signals, including SIGSTOP, were introduced as a form of inter-process communication (IPC) and control. SIGSTOP specifically became a critical component of job control, allowing users to manage multiple tasks within a single terminal session by suspending and resuming processes. Its reliability (being unblockable) has ensured its consistent role in system administration and debugging over decades of Unix and Linux evolution.