Stopped by Ctrl+Z (SIGTSTP)
Production Risk
Low in interactive use; trap TSTP in automated scripts that must not be suspended.
Exit code 148 (128+20) indicates the process was stopped by SIGTSTP, typically via Ctrl+Z. Unlike termination signals, SIGTSTP suspends the process; it can be resumed with fg or bg.
- 1User pressed Ctrl+Z in the terminal
- 2Another process sent kill -TSTP PID
User presses Ctrl+Z to suspend a process.
#!/bin/bash # In terminal: run a command, then press Ctrl+Z sleep 100 # [1]+ Stopped sleep 100 # Resume with: fg or bg
expected output
^Z [1]+ Stopped sleep 100
Fix 1
Resume a stopped job
WHEN After Ctrl+Z suspends a process
# Resume in foreground fg # Resume in background bg # List stopped jobs jobs -l
Why this works
fg sends SIGCONT and waits for the job; bg sends SIGCONT and runs the job in the background.
Fix 2
Prevent Ctrl+Z in critical scripts
WHEN A script must not be suspended mid-execution
#!/bin/bash trap '' TSTP # Ignore SIGTSTP critical_operation # Ctrl+Z will now do nothing while this script runs
Why this works
Trapping TSTP with an empty handler (trap '' TSTP) makes the process ignore Ctrl+Z.
GNU Bash Manual — Job Control Signals
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev