Closed greatghoul closed 4 years ago
其实 CTRL+Z
发送的是 SIGTSTP 信号,也就是挂起终端/终端停止,如果程序有相应的话说明程序对这个信号做了处理,程序并没有卡死,可能只是某个线程无法退出导致的。
如果程序没有对 SIGTSTP 做处理的话,那么这个信号也是可以忽略的(也有无效的可能性)
https://www.gnu.org/software/libc/manual/html_node/Job-Control-Signals.html https://stackoverflow.com/questions/11886812/whats-the-difference-between-sigstop-and-sigtstp
原来还有这样的区别,那其实遇到的卡死也不是真正意义上的卡死,只是 CTRL_C 结束不了,CTRL_Z 还能响应的情况。
@yitong-ovo
在 Ruby on Rails 的日常开发时,有时候不小心写出个坏代码(比如死循环),导致 rails dev server 进程失去响应,这时候如果想杀掉进程,按
Cmd+C
可能没有效果。除了去 grep ps 或者查看 server.pid 外,还有一个快捷的方法快速结束进程。
按下
Cmd+Z
,进程会自动转到后台运行,此时终端上会输出进程 PIDkill 掉它就可以了。