raising SIGUSR on key press

What is the best way to have a keypress raise a user signal? I dont want a to use a thread that reads all input and raises an exception on a specific key because this would make input for other threads tedious.

for example i want the program to receive a SIGUSR1 signal every time i press ctrl+F1 without having to create a thread that constantly reads the input buffer.

thx pfoh
That seems to be a very odd way to do it. Most applications will implement their own event loop in the main thread and signal child threads as appropriate.

In general, only one thread should read any given input stream. For the standard streams it should be the main thread. Trying to multiplex stream access across multiple threads is far more a headache than having one thread signal other(s) when input is received.

But if you must go the other way, you can check out man 9 request_irq
http://www.google.com/search?hl=en&q=man+9+request_irq&btnG=Search

Good luck!

[edit]
Oh yeah, JSYK, I haven't ever done anything this weird in Linux before, so I don't know if there is a better way or not. ;-)
Last edited on
Topic archived. No new replies allowed.