I have a process using sockets, database connections and the likes. It is basically a server process relaying between sensor data and a web interface, and as such it is important to ensure the application, if killed, terminates gracefully.
How do I handle unexpected exceptions such as segfaults (at least for debugging) as well as kill signals so that I can close any connections and stop any threads running so that the process does not leave a mess of anything it is using?
SIGKILL
as to not confuse people who have never used anything other than the commandkill
from the shell ;) – DanyelSIGTERM
andSIGINT
is a very common practice to allow you to sanely exit. – Danyel