148
BashINFOCommonSignalHIGH confidence

Stopped by Ctrl+Z (SIGTSTP)

Production Risk

Low in interactive use; trap TSTP in automated scripts that must not be suspended.

What this means

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.

Why it happens
  1. 1User pressed Ctrl+Z in the terminal
  2. 2Another process sent kill -TSTP PID
How to reproduce

User presses Ctrl+Z to suspend a process.

trigger — this will error
trigger — this will error
#!/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 a stopped job
# 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

Prevent Ctrl+Z in critical scripts
#!/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.

Sources
Official documentation ↗

GNU Bash Manual — Job Control Signals

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Bash errors