Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!lll-lcc!ames!ucbcad!ucbvax!hplabs!hpcea!hpsrla!darrylo From: darrylo@hpsrla.HP.COM (Darryl Okahata) Newsgroups: comp.sys.ibm.pc Subject: Re: signal() for Turbo C Message-ID: <2670002@hpsrla.HP.COM> Date: Sun, 23-Aug-87 17:10:31 EDT Article-I.D.: hpsrla.2670002 Posted: Sun Aug 23 17:10:31 1987 Date-Received: Wed, 26-Aug-87 05:29:38 EDT References: <1009@bsu-cs.UUCP> Organization: Network Measurements Div - Santa Rosa, CA Lines: 42 In comp.sys.ibm.pc, dhesi@bsu-cs.UUCP (Rahul Dhesi) writes: > #! /bin/sh > # This is a shell archive, meaning: > # 1. Remove everything above the #! /bin/sh line. > # 2. Save the resulting text in a file. > # 3. Execute the file with /bin/sh (not csh) to create: > # signal.c > # signal.man > # This will give you the C source and the manual for an implementation > # of signal() for Turbo C. Only SIGINT is currently recognized. > # [ ... ] Thanks to Rahul Dhesi for writing this! However, there are little "gotchas" that one has to be careful of: 1. Any routine called through the handler set up by the ctrlbreak() call uses the stack given to it by DOS. The handler does not set up a stack before calling the specified routine. It *appears* that the stack used is the one that was being used when the DOS function that was called was interrupted. Because of this, there may or may not be enough room on the stack for the ctrl-break handler to properly run (there may not be enough room for local variables, recursive calls, etc.). 2. As the stack that is being used may not be the one that Turbo C uses, the Turbo C program may terminate if stack overflow checking is turned on. In my case, a TSR (Chris Dunford's PCED) was doing some processing when I hit CTRL-C. Because PCED sets up a local stack and because I had turned on stack overflow checking in my Turbo C program, the Turbo C program was aborting with a "stack overflow" error upon entry to main_handler(). -- Darryl Okahata UUCP: { hplabs!hpcea, hpfcla }!hpsrla!darrylo CompuServe: 75206,3074 Disclaimer: the above is the author's personal opinion and is not the opinion or policy of his employer or of the little green men that have been following him all day.