Bash Script to Show ALL the Signal That Were Received
Fleetingasked to chatgpt
#!/bin/bash
set -o errexit # -e
set -o errtrace # -E
set -o nounset # -u
set -o pipefail
shopt -s inherit_errexit
# ctrl-c
trap "exit 2" SIGINT
trap "exit 3" SIGQUIT
# Function to handle signals
handle_signal() {
echo "I received signal $1"
}
# Trap all signals from 1 to 64
for sig in $(seq 1 64); do
# Ignore certain signals that cannot be trapped (e.g., 9, 19)
if ! kill -l $sig 2>/dev/null | grep -q "Invalid"; then
trap "handle_signal $(kill -l $sig)" $sig
fi
done
echo here we go
sleep 36000