How Ctrl-C is distributed via tmux

I know that when I press Ctrl-C, the pts system of the operating system interprets it and sends it SIGINTto the foreground process group. I'm just wondering how it spreads through tmux.

Let's say I run regular Linux with an X server and a window manager. I opened it xtermand zshworks in it tmux. In this, tmuxI run a bashand in it a ./a.out.

A process tree similar to window managerxtermzshtmux client. Then tmux serverbash./a.out.

So, when I press Ctrl-C on my keyboard, the X server first catches it and tells the active window xterm"hey, this guy just hit Ctrl-C". xtermtells the directly running process ( zsh) that I hit Ctrl-C by sending the pts/0"Ctrl-C" character to the pseudo-terminal . The operating system saw the "Ctrl-C" symbol in the pseudo-terminal and translates it into SIGINTthe foreground process group (which is zshand tmux client). Then he tmux clienthad to get this one SIGINT, so he reports tmux serverand tmux server, and then sends SIGINTto the foreground process group the just created pseudo-terminal (with bashand ./a.outin it), Sorry if everything looks confusing. But because of how it tmuxworks,tmux serverandtmux client are two separate processes.

Now, if I want to imitate this behavior, I could just send SIGINTin tmux clientand expect to ./a.outreceive SIGINT, as if I just pressed "Ctrl-C" on my keyboard. But nothing happens. I guess I'm wrong somewhere and can you help me?

+4
source share

Source: https://habr.com/ru/post/1661071/


All Articles