What is the most convenient and clear way to handle program cleanup when receiving a Ctrl+C?
For example when my socket server gets killed this way, the TCP socket never gets closed. I would like a nice one liner I can put at the top of the program to set a sigint handler (or something like atexit) to close certain sockets (or doing any other kind of cleanup) before terminating the program.
It's easy to handle signals by assigning signal handlers via the %SIG
hash. More details can be found at perlipc.
Can't be quicker, more convenient or clearer than sigtrap.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With