0

When a terminal is disconnected, the OS kernel sends SIGHUP to the controlling process of the terminal.

When a terminal emulator terminates, who sends SIGHUP to the controlling process of the pseudoterminal underlying the terminal emulator: the OS kernel or the terminal emulator?

Thanks.

3

The answer is already contained in your question. When a terminal is disconnected, the kernel sends SIGHUP to the controlling process of the terminal¹. For a terminal created by a driver in the kernel, the terminal is disconnected when the driver says so. For a pseudoterminal, the terminal is disconnected when the file handle for the master side of the terminal is closed (either because the terminal emulator process closed it explicitly or because the terminal emulator process died)³.

¹ The controlling process is whatever process ran first in the terminal — more precisely, it's the first process that either opened the terminal while being a session leader or became a session leader while having the terminal open, if this process still is a session leader.
² The master side is the side of the emulator. The slave side is the side of the application running in the terminal.
³ If more than one process has the master side of the terminal open, they must all close their file descriptors (possibly by dying), so that the file descriptor is closed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.