What keyboard signal apart from Ctrl-C can I catch

2019-06-18 05:30发布

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?

标签: c linux signals
3条回答
乱世女痞
2楼-- · 2019-06-18 06:00

You can use ctrl+Z,

SIGTSTP 

Value = 20

For more details refer this link.

查看更多
3楼-- · 2019-06-18 06:00

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

查看更多
乱世女痞
4楼-- · 2019-06-18 06:02

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>.

查看更多
登录 后发表回答