138
BashINFOCommonSignalHIGH confidence
User-defined signal 1 (SIGUSR1)
Production Risk
Without a handler, SIGUSR1 kills the process; always trap it in long-running services.
What this means
Exit code 138 (128+10) indicates the process received SIGUSR1. This signal has no predefined meaning — applications define their own handler for it. The default action (when no handler is set) is to terminate the process.
Why it happens
- 1Another process sent kill -USR1 PID
- 2A process manager uses SIGUSR1 for a specific action (e.g., log rotation in some daemons)
How to reproduce
Sending SIGUSR1 to a process with no handler.
trigger — this will error
trigger — this will error
#!/bin/bash sleep 100 & PID=$! kill -USR1 $PID wait $PID echo "Exit: $?"
expected output
Exit: 138
Fix
Trap SIGUSR1 for custom application actions
WHEN Writing daemons or long-running scripts
Trap SIGUSR1 for custom application actions
#!/bin/bash
rotate_logs() {
mv /var/log/myapp.log /var/log/myapp.log.1
echo "Logs rotated at $(date)" > /var/log/myapp.log
}
trap rotate_logs USR1
echo "Running, PID $. Send USR1 to rotate logs."
while true; do
sleep 1
doneWhy this works
Trapping USR1/USR2 lets you implement operational controls (log rotation, status dump, reload) without stopping the service.
Sources
Official documentation ↗
GNU Bash Manual — Signals
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev