alarms during a read()

Michael A. Cooper mcooper at usc-oberon.UUCP
Tue Aug 5 09:38:53 AEST 1986


-=-=

[VAX 4.2BSD]

I've been trying to figure out how to jump out of a read()
via a signal alarm.  My problem is that things wedge up
when (apparantly) read() is restarted when the alarm goes
off.  This occurs when there is no input for read() to read.
Hence, wakeup() is never called by the alarm.  Below is the 
basic code:

			signal(SIGALRM, wakeup);
			alarm(3);
			recvbuf[0] = getch();
			alarm(0);

And here's getch()...

			getch()
			{
				char c;

				(void) read(0, &c, 1);
				return(c & 0377);
			}

According to the signal(3c) manual:

    "If a caught signal occurs during certain system calls, caus-
     ing the call to terminate prematurely, the call is automati-
     cally restarted.  In particular this can occur during a read
     or write(2) on a slow device (such as a terminal; but not a
     file) and during a wait(2)."

I assume this is my problem.  Now, has anyone figured out a way
around this?  It seems that catching a signal during certain
system calls should not be a problem.  It's not too much to ask
for, is it?


-- 
Michael Cooper, U of Southern California Computing Services, (213) 743-3462
  UUCP: {sdcrdcf, uscvax}!usc-oberon!mcooper
  ARPA: mcooper at usc-oberon.arpa 		BITNET: mcooper at uscvaxq



More information about the Comp.unix.wizards mailing list