使用命令行快捷方式发送 SIGTERM

mh-*_*bon 5 keyboard-shortcuts command-line

我希望能够使用命令行快捷方式发送 SIGTERM 信号,就像我可以使用Ctrl+发送 SIGINT 一样C

我之前读过关于ctrl+ 的内容d,但这在这里不起作用,什么也没有发生。

我还使用键盘快捷键阅读了这个 SO SIGTERM

$ stty -a
speed 38400 baud; rows 43; columns 123; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q;
stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -extproc
Run Code Online (Sandbox Code Playgroud)

退出我想触发的信号吗?是杀死我想触发的信号吗?

非常愚蠢......如何在我的键盘上输入'^\'或'^U'?我只需输入然后按回车键?

Jos*_*eia 10

不能SIGTERM从命令行发送并不完全正确。您不能从键盘快捷键发送它,但您可以从命令行发送它。

根据kill手册页,您可以将 a 发送SIGTERM到任何进程。您可以通过在流程表中找到您的流程(类型ps)然后输入来完成此操作kill -15 [pid]

以下是您可以在终端中用于处理进程的键盘快捷键列表:

  • Ctrl+C发送SIGINT要求中断程序但可以被捕获或忽略的。
  • Ctrl+Z发送SIGTSTP要求暂停程序但可以被捕获或忽略的。这个过程可以在以后恢复。
  • Ctrl+\发送SIGQUITSIGINT除了它还会产生核心转储之外相同。

来源 1来源 2

  • `kill -15 &lt;pid&gt;` 或 `kill -s SIGTERM &lt;pid&gt;` (7认同)
  • 请注意,“kill”发送的默认信号是“SIGTERM”,因此您的“kill”命令可以只是“kill [pid]”。 (5认同)

Ioa*_*dis 7

不,SIGTERM不能从命令行发送,如:https : //superuser.com/a/343611/199930 所述

另见:https : //unix.stackexchange.com/q/362559/43390