What's the difference between SIGSTOP and SIGTSTP?

一笑奈何 提交于 2019-11-26 18:53:08

问题


That's it. Just wondering about the difference between SIGSTOP and SIGTSTP.


回答1:


Both signals are designed to suspend a process which will be eventually resumed with SIGCONT. The main differences between them are:

  • SIGSTOP is a signal sent programmatically (eg: kill -STOP pid ) while SIGTSTP (for signal - terminal stop) may also be sent through the tty driver by a user typing on a keyboard, usually Control-Z.

  • SIGSTOP cannot be ignored. SIGTSTP might be.




回答2:


/usr/include/x86_64-linux-gnu/bits/signum.h

#define SIGSTOP     19  /* Stop, unblockable (POSIX).  */
#define SIGTSTP     20  /* Keyboard stop (POSIX).  */



回答3:


SIGSTOP can't be ignored by the targetted process.

A good example of that is the video player mpv, it can ignore SIGTSTP but not SIGSTOP.

You can test with a video running :

kill -SIGTSTP $(pidof mpv) and kill -SIGSTOP $(pidof mpv)

Of course kill -SIGCONT $(pidof mpv) to resume playing.



来源:https://stackoverflow.com/questions/11886812/whats-the-difference-between-sigstop-and-sigtstp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!