trap
The trap shell built-in supports numbers (0, 1, 2, 3, 15, etc), long names (EXIT, SIGHUP, SIGINT, SIGQUIT, SIGTERM, etc), and short names (EXIT, HUP, INT, QUIT, TERM, etc). Use long names:
1
trap "echo EXIT" EXIT
2
trap "echo received hangup signal" SIGHUP
3
trap "echo received interrupt signal" SIGINT
4
trap "echo received quit signal" SIGQUIT
5
trap "echo received terminate signal" SIGTERM
Copied!
Copy link