Quote:
Originally Posted by
saeed13r
I'd never known that there is a session between processes and the terminal, how come is this?
You probably know roughly what it's doing - foreground and background processes, SIGINT on ctrl-c, any background process clutter cleaned up with SIGHUP when you quit, et cetera. This is the minutae on how the OS accomplishes that. It needs to know what processes belong to you to do that, and "you" means your login - i.e. your
controlling terminal.
This assumption goes pretty deep. Things like sudo and ssh directly talk to your controlling terminal to get passwords securely, in the expectation that a terminal is a direct realtime line to the user - and if there isn't any controlling terminal, it shouldn't even try to ask for a password.
This control scheme goes all the way back to serial line modems. Some features come directly from that - like process cleanup on exit. When a serial line modem disconnects, it tells the operating system, causing the operating system to send SIGHUP - hangup - to all the processes spawned from it!