Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!ge-dab!tarpit!bilver!alex From: alex@bilver.uucp (Alex Matulich) Newsgroups: comp.sys.amiga.programmer Subject: Re: Dumb windows from SAS/C programs on Workbench Message-ID: <1991May16.035621.7979@bilver.uucp> Date: 16 May 91 03:56:21 GMT References: <1991May14.164909.19186@NCoast.ORG> Organization: W. J. Vermillion - Winter Park, FL Lines: 32 In article <1991May14.164909.19186@NCoast.ORG> davewt@NCoast.ORG (David Wright) writes: > On a related note, what do you have to do to kill the CTRL-C trapping >their startup code puts in by default. I have my own trapper which worked >fine in Draco programs, but SAS/C seems to grab the signals before I have >a chance to see them, and is dumping my programs without giving me a chance to >clean up, close files, etc. This is what works for me, on every platform I've tried, including Amiga: #include void ctrlctrap(int); /* prototype for ctrl-c trap handler */ main() { signal(SIGINT, ctrlctrap); /* cause ctrl-c to execute ctrlctrap() */ [etc..] } void ctrlctrap(int i) /* i is needed because signal() passes it */ { signal(SIGINT, ctrlctrap); /* do ctrlctrap() on next ctrl-c event */ } This will just cause all ctrl-c's to be ignored. If you want to actually do something else, like clean up allocated memory and shut down, just replace the signal() call in ctrlctrap() with whatever you want to do, free() this and that, close libraries, etc. -- _ |__ Alex Matulich /(+__> Unicorn Research Corp, 4621 N Landmark Dr, Orlando, FL 32817 //| \ UUCP: alex@bilver.uucp ...uunet!tarpit!bilver!alex ///__) bitnet: IN%"bilver!alex@uunet.uu.net"