ncgus@ndsuvax.UUCP (Jim Gustafson) (07/27/88)
Can someone explain why the following code works fine on a VAX 11/780 but barfs (never exits loop) on an AST-286 running MSDOS 3.2 w/ TC V1.5? Thanks. /* * demo.c -- test ssignal() in TC */ #include <stdio.h> #include <signal.h> #ifdef VAX # define ssignal signal #endif main() { int cleanup(); ssignal(SIGINT, cleanup); printf("Infinite Loop: hit ctl-c to enable SIGINT\n"); for(;;) ; } int cleanup() { fprintf(stderr, "cleanup() enabling SIGINT\n"); ssignal(SIGINT, SIG_DFL); } -- -- Jim Gustafson UUCP: uunet!ndsuvax!ncgus North Dakota State University Bitnet: ncgus@ndsuvax Fargo, North Dakota 58105 Internet: ncgus@plains.nodak.edu
kneller@cgl.ucsf.edu (Don Kneller) (07/29/88)
In article <1056@ndsuvax.UUCP> ncgus@ndsuvax.UUCP (Jim Gustafson) writes: > >Can someone explain why the following code works fine on a VAX 11/780 >but barfs (never exits loop) on an AST-286 running MSDOS 3.2 w/ TC V1.5? >Thanks. >#ifdef VAX ># define ssignal signal >#endif > >main() >{ > int cleanup(); > > ssignal(SIGINT, cleanup); > printf("Infinite Loop: hit ctl-c to enable SIGINT\n"); > for(;;) > ; Although not familiar with TC's ssignal() [ How does it differ from signal()? ] I think your problem is that, by default, DOS does not check for ^C unless it is doing IO (which your infinite loop is not doing). You can make DOS check for ^C "more often" by putting a "BREAK=on" line in your CONFIG.SYS file. That should fix your problem. BTW, does anyone know the difference between ^C and ^BREAK? I have found that if ^C is *not* the first character in the type-ahead buffer, DOS won't abort, but ^BREAK will always make DOS abort. Is this perhaps a function of my software buffer expander? - don ----- Don Kneller UUCP: ...ucbvax!ucsfcgl!kneller INTERNET: kneller@cgl.ucsf.edu BITNET: kneller@ucsfcgl.BITNET
Ralf.Brown@B.GP.CS.CMU.EDU (07/29/88)
In article <11061@cgl.ucsf.EDU>, kneller@cgl.ucsf.edu (Don Kneller) writes: }Although not familiar with TC's ssignal() [ How does it differ from }signal()? ] ssignal() is a purely software signal, and is invoked only by gsignal(). }BTW, does anyone know the difference between ^C and ^BREAK? I have }found that if ^C is *not* the first character in the type-ahead buffer, }DOS won't abort, but ^BREAK will always make DOS abort. Is this }perhaps a function of my software buffer expander? No, the keyboard routine in ROM generates an INT 1Bh when it detects ^Break, and DOS traps that interrupt and sets the ^C flag. The keyboard routine also clears the keyboard buffer, but that may not affect your buffer expander. A ^C has to be the first character in the buffer because DOS peeks at the next character only, since it doesn't buffer keyboard input itself (you'd see some strange results with programs that use the BIOS functions to read the kbd if it did). -- UUCP: {ucbvax,harvard}!cs.cmu.edu!ralf -=-=-=- Voice: (412) 268-3053 (school) ARPA: ralf@cs.cmu.edu BIT: ralf%cs.cmu.edu@CMUCCVMA FIDO: Ralf Brown 1:129/31 Disclaimer? I |Ducharm's Axiom: If you view your problem closely enough claimed something?| you will recognize yourself as part of the problem.
platt@emory.uucp (Dan Platt) (07/29/88)
First, apologies for posting this kind of reply on the net; we have a tiny /etc/hosts file.... Anyway... The reason that ssignal won't vacate the loop is two-fold; First, SIGINT isn't supported with ssignal under TC1.5. They are thinking of getting rid of ssignal all together (not part of the ANSI draft). Instead, there is a function ctrlbrk() which does the same thing for the SIGINT case. Second, SIGINT would only be supported if i/o was executed... the program wouldn't ever 'see' the ^C. Dan
void@rena.dit.JUNET (Y.Kusakabe) (07/31/88)
Turbo-C's ssignal() is NOT equal unix's signal(). Don't #define `signal' as `ssignal'. Please read your `Turbo-C Reference Manual'. --------------------------------------------- Youichi Kusakabe void%lyra.dit.junet@uunet.uu.net Miyasaka Setagaya-ku Tokyo JAPAN 156 ---------------------------------------------
dhesi@bsu-cs.UUCP (Rahul Dhesi) (08/03/88)
Since there seems to be some interest in this, I will post my signal() emulation package for Turbo C to comp.binaries.ibm.pc. (Actually it's small and simple and you can write your own but it seems not everybody realizes this.) -- Rahul Dhesi UUCP: <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!dhesi