I'm trying to write a mail program which might contain data that a user wouldn't want to lose upon a broken SSH/telnet connection. Would
SIGHUP be sent to the process? After all, it's the "hangup" signal...
By default the process will be sent a
SIGHUP. The default signal handler (trap) will shutdown the program relatively gracefully, but won't save the users work.
In your case, I would have the program include a trap routine that saves the user's work when a
SIGHUP is received. You can catch and handle all signals except
SIGKILL. You may also want to run the same routine for a
There are other mechanisms that can be used to avoid getting a
SIGHUP signal, but handling the signal is the simplest and safest. If the other approachs fail, or a
SIGHUP is sent with the
kill command your process would still shutdown without saving the work.