-3

A signal is sent by or from a process to another process.

A bash process is usually run in a terminal emulator process such as gnome terminal.

A bash process in turn runs other processes.

So when we send a signal to a process using control keys or running kill in a terminal emulator which runs bash, which process sends the signal to which process? how are th terminal emulator process, the bash process, and the child processes of the bash process involved?

Thanks.

Tim
  • 101,790

1 Answers1

2

When executing the kill commands that are built-in to various shells, it is the shell process itself that is executing the system call to send the signal.

When executing an external kill command, it is the process forked to run that program that is executing the system call to send the signal.

There is no such thing as "a pseudo terminal process". Pseudo terminals are not processes. There is a terminal emulator process, but that emulator is not the pseudo terminal.

When a special character is sent from a terminal, or from a terminal emulator via the master side of a pseudo-terminal, to the line discipline in the kernel, then (assuming that the line discipline has the terminal in canonical input mode where special characters are special) it is the kernel that sends the signal.

Further reading

JdeBP
  • 68,745
  • 1
    terminal delivery upon ^C/^Z/... is independent of the canonical mode. You need isig to be on in the output of stty -a for it. – Stéphane Chazelas Aug 08 '17 at 12:07
  • Thanks. (1) From my modification of Stephane Chazelas' reply, "The manual talks about signal delivery to the shell, not to the commands you run from that shell." In that case, what process sends signals to the shell? (2) Also the same reply mentions that, when running sleep 1000 in a bash interactive shell, ctrl-C will send SIGINT to the process running sleep 1000. In that case, which process sends SIGINT to the sleep 1000 process? – Tim Aug 09 '17 at 18:47
  • If I understand https://unix.stackexchange.com/a/120071 correctly, are the sender of the signals in both (1) and (2) the tty line discipline in the terminal emulator's driver in the kernel? – Tim Aug 09 '17 at 20:19
  • s/terminal( delivery)/signal$1/ above sorry. – Stéphane Chazelas Sep 03 '17 at 17:22