136
BashCRITICALCriticalSignalHIGH confidence

Floating-point exception (SIGFPE)

Production Risk

In bash, division by zero exits with 1 not 136; 136 appears when a child process receives SIGFPE.

What this means

Exit code 136 (128+8) indicates SIGFPE — a floating-point exception. Despite the name, this also covers integer division by zero, which is the most common cause in shell scripting contexts.

Why it happens
  1. 1Integer division by zero in a C program called from the script
  2. 2Arithmetic expression $(( n / 0 )) in bash itself
  3. 3Floating-point overflow or invalid operation in a compiled program
How to reproduce

Bash arithmetic division by zero.

trigger — this will error
trigger — this will error
#!/bin/bash
echo $(( 10 / 0 ))
echo "Exit: $?"

expected output

bash: 10 / 0: division by zero (error token is "0")
Exit: 1

Fix

Guard against zero divisors

WHEN Performing division in scripts

Guard against zero divisors
divisor=$1
if [ "$divisor" -eq 0 ]; then
  echo "Error: divisor cannot be zero" >&2
  exit 1
fi
result=$(( 100 / divisor ))

Why this works

Always validate divisors before performing division; division by zero is undefined.

What not to do

Use bc or awk without checking the divisor

bc and awk also error on division by zero, though they may produce different exit codes.

Sources
Official documentation ↗

GNU Bash Manual — Signals

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

← All Bash errors