CPU time limit exceeded (SIGXCPU)
Production Risk
Common in HPC/batch environments; investigate runaway loops or optimize CPU-intensive operations.
Exit code 152 (128+24) indicates the process exceeded the CPU time limit set by ulimit -t or setrlimit(RLIMIT_CPU). The kernel sends SIGXCPU when the soft limit is reached, then SIGKILL at the hard limit.
- 1A process ran longer than the CPU time limit set with ulimit -t
- 2A runaway loop consuming CPU beyond the allowed budget
- 3Batch job systems enforcing per-job CPU limits
A CPU-intensive process hits the ulimit -t limit.
#!/bin/bash # Set a 2-second CPU time limit (ulimit -t 2; while true; do :; done) echo "Exit: $?"
expected output
CPU time limit exceeded Exit: 152
Fix 1
Increase the CPU time limit
WHEN The limit is too low for legitimate workloads
# Increase CPU time limit (seconds) ulimit -t 3600 # 1 hour your_cpu_intensive_command
Why this works
ulimit -t sets the maximum CPU time in seconds; increase it if the workload is legitimately long.
Fix 2
Optimize the computation or add progress checks
WHEN A loop may be infinite due to a bug
#!/bin/bash
count=0
while process_next_item; do
count=$((count + 1))
if [ $((count % 1000)) -eq 0 ]; then
echo "Processed $count items..." >&2
fi
doneWhy this works
Adding progress logging helps diagnose whether the loop is making progress or is stuck.
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev