Fedora Linux: Way to use stty (or equivalent) to bind key to raise SIGUSR1 for application?

4

1

I'm using FC 14, but this is probably a fairly generic Linux question.

I want to be able to bind a key in the Linux terminal driver that will cause a signal other than SIGINT or SIGQUIT to be raised for the running application. I don't want to co-opt either of those. If it rings a bell for you, think along the lines of the old CTRL/T capability, only with the signal being caught and handled by the app rather than the OS.

Since this is for status reporting for long-running activities, SIGUSR1 seems appropriate. However, if specifically raising that from the terminal keyboard isn't an option, I'll take what I can get. I don't want to attempt the impossible and catch SIGKILL B-) but I would like to be able to raise signals other than SIGQUIT and SIGINT from the terminal keyboard.

Scenario:

  1. Set up the terminal to do the signal-raising thing
  2. Run application from shell in terminal window
  3. Wait until it gets into the complex long-running section
  4. Press CTRL/whatzit to raise the signal
  5. Application catches the signal, does some sort of status report, and resumes

I could do this with no problems on VMS/OpenVMS, and it kinda frosts my pumpkins to think it's more difficult on Linux.

RoUS

Posted 2011-07-11T20:00:49.823

Reputation: 141

Answers

2

The interface for raising signals via magic characters is, unfortunately, not a generic bind-character-to-signal thing - there are certain specific signals which can be raised like this, and you get to choose the character, but not the signal: see the relevant chapter of the POSIX specification.

(Apart from SIGINT and SIGQUIT, your other option for co-opting a signal is SIGTSTP, if you can live without being able to stop your process with ^Z - which I guess might be the case if you're expecting to leave it running in the foreground anyway.)

Matthew Slattery

Posted 2011-07-11T20:00:49.823

Reputation:

That's what I feared. Thanks for the pointer and the answer! – None – 2011-07-13T16:51:38.840