Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!uwm.edu!rpi!dali.cs.montana.edu!uakari.primate.wisc.edu!crdgw1!ge-dab!tarpit!bilver!alex From: alex@bilver.UUCP (Alex Matulich) Newsgroups: comp.os.msdos.programmer Subject: Re: Need help:Ctrl-C and Ctrl-Break Keywords: signal, control break Message-ID: <870@bilver.UUCP> Date: 3 Aug 90 17:14:48 GMT References: <1990Jul30.182430.7493@uokmax.uucp> <9627@tekigm2.MEN.TEK.COM> Organization: William J. Vermillion, Winter Park, FL Lines: 39 In article <9627@tekigm2.MEN.TEK.COM> dennisw@tekigm2.MEN.TEK.COM (Dennis G Ward) writes: >I've got a truly great program underway, but I can't stand to let the >user break out of it with Ctrl-C or Ctrl-Break, and I need keyboard >input. What's the trick(s)? The most PORTABLE way to do it (and it works well too) is to use the signal() function in the standard library, like so: --------------------------------------- #include void ctrlctrap(i) int i; { signal(SIGINT, ctrlctrap); /* make sure next ctrl-break comes back here */ } void main() { signal(SIGINT, ctrlctrap); /* activate ctrl-c/ctrl-break trap handler */ etc.... -------------------------------------- Every time ctrl-c or ctrl break is pressed, the funtion ctrlctrap() will be invoked, and will reset the pointer for the next ctrl-c to call ctrlctrap() again. This has worked on every ANSI compiler I have tried it on (Lattice, Microsoft, unix compilers, etc.) -- /// Alex Matulich /// Unicorn Research Corp, 4621 N Landmark Dr, Orlando, FL 32817 \\\/// alex@bilver.UUCP ...uunet!tarpit!bilver!alex \XX/ From BitNet try: IN%"bilver!alex@uunet.uu.net"