给定一个 shell 进程(例如sh
)及其子进程(例如cat
),如何使用 shell 的进程 ID模拟Ctrl+的行为C?
这是我尝试过的:
运行sh
然后cat
:
[user@host ~]$ sh
sh-4.3$ cat
test
test
Run Code Online (Sandbox Code Playgroud)
发送SIGINT
到cat
从另一终端:
[user@host ~]$ kill -SIGINT $PID_OF_CAT
Run Code Online (Sandbox Code Playgroud)
cat
收到信号并终止(如预期)。
向父进程发送信号似乎不起作用。为什么信号cat
在发送到其父进程时没有传播到sh
?
这不起作用:
[user@host ~]$ kill -SIGINT $PID_OF_SH
Run Code Online (Sandbox Code Playgroud) $ help suspend
suspend: suspend [-f]
Suspend shell execution.
Suspend the execution of this shell until it receives a SIGCONT signal.
Run Code Online (Sandbox Code Playgroud)
我应该如何向suspend
在 gnome 终端选项卡中挂起的外壳发送 SIGCONT 信号?