[英]Why do I receive two SIGCONT signals?
我正在编写一个设置终端属性的程序,所以我必须在脚本退出的任何时候重置终端,包括如果用户按下 ^Z,但是当我用 fg 重新输入命令时,SIGCONT 信号被发送两次,但我只希望它被调用 1 次。 为什么会发生两次? 这是一个显示问题的简短程序:
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
void sigtstp (int signum) {
write(1, "got a SIGTSTP\n", 14);
kill(getpid(), SIGSTOP);
}
void sigcont (int signum) {
write(1, "got a SIGCONT\n", 14);
}
int main (int argc, char **argv) {
signal(SIGTSTP, sigtstp);
signal(SIGCONT, sigcont);
while (1) {
sleep(100);
}
}
output是这样的:
% clang cont.c -o cont
% ./cont
^Zgot a SIGTSTP
zsh: suspended (signal) ./cont
% fg
[5] continued ./cont
got a SIGCONT
got a SIGCONT
^C
我在 macOS 上使用 zsh。
这是 zsh 版本 5.7、5.7.1、5.8 和 5.8.1 中的一个已知错误。 它由 Erik Paulson 为 zsh 5.9 修复:
https://www.zsh.org/mla/workers/2021/msg01255.html
在 Ubuntu 20.04 - 22.04 上,此 zsh 错误导致fg
有时无法恢复停止的vim
。 由于某些未知原因,额外的 SIGCONT 导致vim
立即再次停止自身。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.