What keyboard signal apart from Ctrl-C can I catch?

寵の児 提交于 2019-12-23 09:33:59

问题


I have a (C, Linux) application which handles Ctrl-C SIGINT by shutting down. I'd like to add another signal handler so that I can use another keystroke combo for "reload configuration while running".

So I'm looking from a signal I can send to the foreground process by keystroke, which doesn't force the process to quit or suspend. Are there any others?


回答1:


You can use ctrl+Z,

SIGTSTP 

Value = 20

For more details refer this link.




回答2:


You can try Ctrl - \ which is SIGQUIT if you absolutely need it to be a keystroke (you can catch it).




回答3:


Your program can use SIGUSR1 and SIGUSR2 to do whatever it wants, but there's no single-stroke way of sending them like how a Ctrl+C sends a SIGINT signal. You have to use something like kill(1) to send the signal, e.g. kill -USR1 <mypid>.



来源:https://stackoverflow.com/questions/9937743/what-keyboard-signal-apart-from-ctrl-c-can-i-catch

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