日期:2014-05-16  浏览次数:20892 次

linux下ctrl+d是啥意思?
当系统启动后,我按ctrl+d,然后我起的一些进程死掉了,串口打印dnsmasq也被信号中断,中断的信号是SIGHUP
我查询ctrl+d有退出shell的意思,
ctl+c:发送信号SIGINT(程序中止)
ctl+d:发送信号SIGTSTP(进程中止)
这个CTRL+d 到底是什么意思,是发送信号SIGTSTP或者SIGHUP,还是退出shell?
我不希望CTRL+d 杀死某些进程如何操作

------解决方案--------------------

对信号函数的从写来实现
setjmp 与 longjmp
------解决方案--------------------
SIGTSTP
 This interactive stop signal is generated by the terminal driver when we type the terminal suspend key (often Control-Z). This signal is sent to all processes in the foreground process group.

Unfortunately, the term stop has different meanings. When discussing job control and signals, we talk about stopping and continuing jobs. The terminal driver, however, has historically used the term stop to refer to stopping and starting the terminal output using the Control-S and Control-Q characters. Therefore, the terminal driver calls the character that generates the interactive stop signal the suspend character, not the stop character.
 
------解决方案--------------------
引用楼主 linkejin 的帖子:
当系统启动后,我按ctrl+d,然后我起的一些进程死掉了,串口打印dnsmasq也被信号中断,中断的信号是SIGHUP
我查询ctrl+d有退出shell的意思,
ctl+c:发送信号SIGINT(程序中止)
ctl+d:发送信号SIGTSTP(进程中止)
这个CTRL+d 到底是什么意思,是发送信号SIGTSTP或者SIGHUP,还是退出shell?
我不希望CTRL+d 杀死某些进程如何操作

------解决方案--------------------
探讨
刚试了下用ctrl+c只是对当前进程起了中断,不会杀死进程,ctrl+z也不会杀死进程,不是说SIGTSTP是由CTRL+z来产生的吗,怎么会不是?
刚搜索了SIGTSTP,发现被杀死的进程程序中也没有关于SIGTSTP的信号处理啊?这是怎么回事?

------解决方案--------------------
探讨
引用:
那为什么我CTRL+d进程死了,CTRL+z进程不死

Key Function
Ctrl-c Kill foreground process
Ctrl-z Suspend foreground process
Ctrl-d Terminate input, or exit shell
Ctrl-s Suspend output
Ctrl-q Resume output
Ctrl-o Discard output
Ctrl-l Clear screen
但是控制字符都是可以用(stty命令)更改的。
楼主可以用stty -a看看终端配置。

------解决方案--------------------
SIGHUP 该信号是说明 该进程组从终端脱离,而被杀死.