Path: utzoo!utgpu!watmath!clyde!att!osu-cis!killer!ames!amdcad!sun!pitstop!sundc!seismo!uunet!nuchat!orion@nuchat From: orion@nuchat (Roland Dunkerley) Newsgroups: comp.unix.wizards Subject: Re: printf, data presentation Message-ID: <2805@nuchat.UUCP> Date: 9 Jan 89 08:38:58 GMT References: <19@xenlink.UUCP> <8800006@gistdev> Sender: orion@nuchat.UUCP Reply-To: orion@nuchat (Roland Dunkerley) Organization: South Coast Computing Services, Houston, Tx. Lines: 50 In-reply-to: flint@gistdev.UUCP In article <8800006@gistdev>, flint@gistdev writes: > >I've found ioctl to be about the least portable thing in UNIX. (FIONREAD >isn't in the SVID, or at least I couldn't find it in TERMIO(BA_ENV) or >IOCTL(BA_OS), so if it is in SVID & I missed it, I'd appreciate being >enlightened.) This is true, System V R3 provides (non-portable) functional equivalants to FIONREAD and the select() call but, it only works on streams devices... Maybe R4 will get it right? > > ..... (For example, if I want my user >to type as many keys as they want to within 10 seconds, and then evaluate >that amount of input, I'm stuck: I have to change the timelimit with each >successive keypress to be "10 - time_used_so_far", and the only way to do >so is with an incredibly slow ioctl() call on each keypress. Some Guru >out there might know some neat way to do this I haven't heard about: >if you know how to do it in Sys V without having to go way out of your >way with something like writing your own device driver, I'd like to hear >your solution.) how about the following: catch() { signal ( SIGINT, catch ); signal ( SIGQUIT, catch ); signal ( SIGALRM, catch ); alarm(0); } /* ...... */ catch(); alarm(10); if( count=read(0, &buffer, buffer_size)==-1 ) { alarm(0); /* Handle failure */ } I think this is portable and should achieve the desired result. We use this in the autobaud section of our local getty. > >Flint Pellett, Global Information Systems Technology, Inc. >1800 Woodfield Drive, Savoy, IL 61874 (217) 352-1165 >INTERNET: flint%gistdev@uxc.cso.uiuc.edu >UUCP: {uunet,pur-ee,convex}!uiucuxc!gistdev!flint Roland Dunkerley III *** (orion@nuchat.UUCP) (uunet.UU.NET!nuchat!orion) *** South Coast Computing Services *** We service Publicly Redistributable software - reasonable rates *** Inquire within