Adopts bash-arithmetic exit-code computation ($((128 + SIGNUM))) instead of piping to bc, dropping that dependency. Consolidates this project onto docker-common's shared scripts (see that repo's CLAUDE.md). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NiNnj78HGx1KWyCCo39HSz
26 lines
451 B
Bash
26 lines
451 B
Bash
signals_trap_with_arg() {
|
|
func="$1" ; shift
|
|
for sig ; do
|
|
echo "$func $sig"
|
|
trap "$func $sig" "$sig"
|
|
done
|
|
}
|
|
|
|
signals_wait_forever() {
|
|
while true
|
|
do
|
|
tail -f /dev/null & wait ${!}
|
|
done
|
|
}
|
|
|
|
signal_name_to_number() {
|
|
SIGNAME="$1"
|
|
trap -l | sed -nr "s/.*\b([0-9]+)\) $SIGNAME.*/\1/p"
|
|
}
|
|
|
|
signal_return_val() {
|
|
SIGNAME="$1"
|
|
SIGNUM=$(signal_name_to_number ${SIGNAME})
|
|
echo $((128 + SIGNUM))
|
|
}
|