How do I catch a KILL or HUP or User Abort signal?
问题 I have a script running on the background of my linux server and I would like to catch signals like reboot or anything that would kill this script and instead save any importante information before actually exiting. I think most of what I need to catch is, SIGINT, SIGTERM, SIGHUP, SIGKILL. How do catch any of these signals and have it execute an exit function otherwise keep executing whatever it was doing ? pseudo perl code: #!/usr/bin/perl use stricts; use warnings; while (true) { #my happy