4 ms·
Well, if you really want to go down the rabbit hole... The shell only gets CTRL+Z when it is in the foreground. The tty driver, which contains a copy of the f
by sophacles 12y ago
Well, if you really want to go down the rabbit hole...
The shell only gets CTRL+Z when it is in the foreground.
The tty driver, which contains a copy of the forground process group id, sees the CTRL+Z, and rather than buffering it to pass to the foreground process, interprets it to send a SIGTSP to the process group that is in the foreground. A well behaving program will either handle the SIGTSTP then send itself a SIGSTOP or just act as if SIGSTOP has been sent. Then a SIGCHLD will be sent to the parent process. (In this case the shell) which can then set another process group or process, including itself, to the foreground process.
Some of the details may vary depending on the terminal line discipline being used... but the important part here is:
The shell isn't actually getting the CTRL+Z, its handled by the tty/pty pair that is in charge of the input at the moment.
Fascinating page about all this here: http://www.linusakesson.net/programming/tty/index.php http://www.linusakesson.net/programming/tty/index.php
- Igglyboo 12y agosomething something keyboard sends electrons across a wire something something