7

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?

blueshift
  • 6,742
  • 2
  • 39
  • 63

3 Answers3

8

You can use ctrl+Z,

SIGTSTP 

Value = 20

For more details refer this link.

Anantha Krishnan
  • 3,068
  • 3
  • 27
  • 37
4

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

cnicutar
  • 178,505
  • 25
  • 365
  • 392
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>.

Adam Rosenfield
  • 390,455
  • 97
  • 512
  • 589
  • 2
    Correct, so that's not what I want. – blueshift Mar 30 '12 at 06:07
  • 2
    @blueshift But keep in mind that those are the signals you are _supposed_ to handle. By changing the others you are creating unexpected behavior. This is not necessarily bad unless you are distributing the program. – Aaron Dufour Mar 30 '12 at 06:13
  • A fair point. But this is internal only, embedded system, not a problem. – blueshift Mar 30 '12 at 06:17
  • 1
    It is a shame. SIGUSR1 and SIGUSR2 are precisely the signals that we can handle better and would be very useful to have keyboard shortcuts for them. – yucer Mar 11 '17 at 05:34