Ubuntu: SIGHUP is not being sent on exit


On ubuntu 14.04.3 (Linux kernel 3.16.53).

UI terminal (created with CTR + ALT + T) set with shopt -s huponexit does not generate SIGHUP when we type exit.

It correctly sends this signal when we click on 'X' to colse the terminal

However it works correctly on tty1.


It is a documented behavior, from man bash:

If the huponexit shell option has been set with shopt, bash sends a SIGHUP to all jobs when an interactive login shell exits.

The important words are "interactive" and "login".

When you open a terminal with Ctrl + Alt + T, you are initiating an interactive, non-login instance of shell, so huponexit won't work as expected.

On the other hand, while opening an TTY with e.g. Ctrl + Alt + F1, you are initiating an interactive, login session of bash, so huponexit will work in this case.

On a different note, when you press the X button on terminal to close it, the terminal driver in the kernel sends SIGHUP to the shell, which in turn sends SIGHUP to all its jobs, more technically all of the foreground and background process groups of the session.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »