Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!nbires!hao!hplabs!ucbvax!cartan!brahms!ballou From: ballou@brahms (Kenneth R. Ballou) Newsgroups: comp.unix.questions,comp.unix.xenix,comp.lang.c Subject: Re: XENIX <-> ULTRIX interrupts & traps Message-ID: <246@cartan.Berkeley.EDU> Date: Tue, 11-Nov-86 14:33:26 EST Article-I.D.: cartan.246 Posted: Tue Nov 11 14:33:26 1986 Date-Received: Wed, 12-Nov-86 02:06:13 EST References: <43@samira.UUCP> Sender: daemon@cartan.Berkeley.EDU Reply-To: ballou@brahms (Kenneth R. Ballou) Distribution: net Organization: Math Dept. UC Berkeley Lines: 46 Xref: mnetor comp.unix.questions:13 comp.unix.xenix:2 comp.lang.c:13 In article <43@samira.UUCP> mike@samira.UUCP (Mike Deutsch) writes: >I have a program written in C which I need to run under both ULTRIX 1.2 >on an 8600 and Microsoft sys V XENIX on an IBM AT. > >In the application, the user enters commands from the keyboard. >I trap interrupts, and go to an interrupt handler when they hit >interrupt. In this handler, I ask the user if they wish to continue >or abort. > >Under XENIX, when the program returns from the interrupt handler, the >program doesn't still expect to be reading at the read where the interrupt >trap was received. Under ULTRIX, it does. > >1) Which one is correct? It's the same code, both C, so one must be wrong. ABSOLUTELY NOT! Library functions are exactly that: library functions. C does not specify how library functions must behave, or even what functions must be provided in an implementation's library. Now, if you browse through signal.h, you will note an error value called EINTR. At least on BSD 4.2, if a signal arrives while read is awaiting data, read returns -1 and errno is set to EINTR: [EINTR] A read from a slow device was interrupted before any data arrived by the delivery of a signal. Again, please note that this is part of UNIX, not of C proper. >2) I'd prefer the program to function as it does under XENIX. How can >I get it to not continue with the read when there was an interrupt during >the read? Since read has returned -1, it seems you could examine the value of errno and repeat the read call if errno is equal to EINTR, viz.: while (read (....) == -1 && errno == EINTR) ; Probably you will want to save the value returned by read for later use. -------- Kenneth R. Ballou ...!ucbvax!brahms!ballou Dept. of Mathematics ballou@brahms.berkeley.EDU University of California Berkeley, California