Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 (Tek) 9/26/83; site hammer.UUCP Path: utzoo!linus!security!genrad!decvax!tektronix!tekgds!tekecs!hammer!steveh From: steveh@hammer.UUCP (Stephen Hemminger) Newsgroups: net.unix-wizards Subject: Re: longjmp + signal may cause problems Message-ID: <390@hammer.UUCP> Date: Tue, 6-Dec-83 18:43:54 EST Article-I.D.: hammer.390 Posted: Tue Dec 6 18:43:54 1983 Date-Received: Fri, 9-Dec-83 03:52:06 EST References: <304@decvax.UUCP> Organization: Tektronix, Wilsonville OR. Lines: 47 -------- The obvious way around the problem with 4.2/4.1c is to use a select and not use a signal at all! /* NOT TESTED */ #include #include int dt_ioget(dt, sec) register DECTALK *dt; /* DECtalk device */ int sec; /* Wait time, 0 == forever */ /* * UNIX: Fill the input buffer, return the next (first) character. */ { register int incount; /* Count and error code */ int fdmask; /* file descriptor mask for select() */ struct timeval timeout; /* timeout value for select() */ /* * Return buffered character (if any) */ if (dt->in_ptr < dt->in_end) return (*dt->in_ptr++ & 0xFF); /* * We must refill the buffer */ dt->in_ptr = dt->in_end = &dt->in_buff[0]; dt_ioput(dt, 0); /* Flush output */ if (dt_abort) return (DT_ERROR); /* Berkeley Unix 4.2 has a nice way of doing this */ fdmask = 1<unit); timeout.tv_usec = 0; timeout.tv_sec = sec; if(select(1, &fdmask, 0, 0, 0, &timeout) < 0) return (DT_ERROR); if(fdmask == 0) return (DT_TIMEOUT) incount = read(dt->unit, dt->in_buff, IN_BUFLEN); dt->in_end = &dt->in_buff[incount]; return (*dt->in_ptr++ & 0xFF); }