Prev: Can't static link with Xlib
Next: I can't figure out how to trap ctrl-z/ctrl-c in the following
From: Brian Bebeau on 9 Feb 2010 11:09 On 2/7/2010 11:43 AM, K-mart Cashier wrote: > I have a program that continuously reads in a text file. What I want > to do is have the program exit when I press either ctrl-z or ctrl-c. > > How would I go about trapping ctrl-c/ctrl-z in this case? You need to catch the SIGINT and SIGSTOP signals. Set a flag in the signal handler that you check later to exit the loop. If you don't already have ctrl-c and ctrl-z set to generate these signals, you'll have to use termios to set them: term.c_cc[VINTR] = \003; term.c_cc[VSTOP] = \032; -- Brian Bebeau bbebeau (at) computer.org
|
Pages: 1 Prev: Can't static link with Xlib Next: I can't figure out how to trap ctrl-z/ctrl-c in the following |