Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 337 Bytes

trap-ctrlc.md

File metadata and controls

26 lines (18 loc) · 337 Bytes

trap ctrl+c

download

function trap_ctrlc()
{
	echo "ctrl+c caught"

	# ctrl+c callback stuffs here

	exit 2
}

# SIGINT=2 ( man 7 signal )
trap "trap_ctrlc" 2

while true; do
	echo "$(date) : loop action"
	sleep 1
done

references