问题
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