Code Comments
Programming Forum and web based access to our favorite programming groups.I have a main.cpp running in a continuous loop. I have two files open and I' ve been stopping the program with control-c. Is this the correct way to stop a unix program? I'd like to get the loop to see the escape key (without polling for it). Or, how can I respond to control-c in the program so that I can close files etc.? thanks, Jim
Post Follow-up to this messageJames Johnson <jjjhnson2-1779231@yahoo.com> writes: > I have a main.cpp running in a continuous loop. I have two files open > and I've been stopping the program with control-c. Is this the correct > way to stop a unix program? I'd like to get the loop to see the escape > key (without polling for it). Or, how can I respond to control-c in > the program so that I can close files etc.? man sigaction Ctrl-C generates a SIGINT. -- Måns Rullgård mru@inprovide.com
Post Follow-up to this messageIn article <yw1x4qiofvs2.fsf@ford.inprovide.com>, Måns Rullgård <mru@inprovide.com> wrote: > James Johnson <jjjhnson2-1779231@yahoo.com> writes: > > > man sigaction > > Ctrl-C generates a SIGINT. Not necessarily. That seems to be the default on Linux and Mac OS X, but many of the Unix systems I've worked on use DEL as the default intr key. To change it to control-C, add "stty intr '^C'" to your login script.
Post Follow-up to this message"Wayne C. Morris" <wayne.morris@this.is.invalid> writes: > In article <yw1x4qiofvs2.fsf@ford.inprovide.com>, > Måns Rullgård <mru@inprovide.com> wrote: > > > Not necessarily. That seems to be the default on Linux and Mac OS X, but > many of the Unix systems I've worked on use DEL as the default intr key. > To change it to control-C, add "stty intr '^C'" to your login script. If the OP had such a system, he wouldn't be using ctrl-c to stop his program. -- Måns Rullgård mru@inprovide.com
Post Follow-up to this messageOn Tue, 14 Dec 2004 21:51:41 +0100, Måns Rullgård <mru@inprovide.com> wrote: >James Johnson <jjjhnson2-1779231@yahoo.com> writes: > > >man sigaction > >Ctrl-C generates a SIGINT. I got control-c to work great using SIGINT. But I'm still wondering if you c an get a unix C main loop to wake up on hitting a key on the keyboard? Jim
Post Follow-up to this messageJames Johnson <jjjhnson2-1779231@yahoo.com> writes: > On Tue, 14 Dec 2004 21:51:41 +0100, Måns Rullgård <mru@inprovide.com> wrot e: > > > I got control-c to work great using SIGINT. But I'm still wondering > if you can get a unix C main loop to wake up on hitting a key on the > keyboard? Sure, just twiddle the mode of your tty properly, and use select(). -- Måns Rullgård mru@inprovide.com
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.