将SIGINT从键盘发送到bash中的管道命令 [英] Sending SIGINT from keyboard to piped commands in bash
本文介绍了将SIGINT从键盘发送到bash中的管道命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果在bash中我在命令行上运行a | b | c | d
,然后按 ^ C ,哪个进程会收到信号?
If in bash I run a | b | c | d
on the command line and then press ^C, which process gets the signal?
推荐答案
简而言之,它们都可以.
In short, they all do.
设置管道时,外壳程序会创建 流程组 .内核的行规将 ^ C 解释为用户请求中断当前在前台运行的进程组的请求.向进程组发送诸如SIGINT
之类的信号会自动将该信号传递给该组中的所有进程.
When setting up a pipeline, the shell creates a process group. ^C is interpreted by the kernel's line discipline as the user's request to interrupt the process group currently running in the foreground. Sending a signal such as SIGINT
to a process group automatically delivers the signal to all processes in the group.
这篇关于将SIGINT从键盘发送到bash中的管道命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文