Xref: utzoo comp.unix.questions:6264 comp.unix.wizards:7386 Path: utzoo!mnetor!uunet!husc6!ncar!gatech!mcnc!decvax!mandrill!hal!ncoast!allbery From: allbery@ncoast.UUCP (Brandon Allbery) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: keypressed()--- and the answer is: Message-ID: <7540@ncoast.UUCP> Date: 23 Mar 88 22:21:29 GMT References: <136@forty2.UUCP> <3961@galbp.LBP.HARRIS.COM> <303@wsccs.UUCP> <2098@ncr-sd.SanDiego.NCR.COM> Reply-To: allbery@ncoast.UUCP (Brandon Allbery) Followup-To: comp.lang.c Organization: Cleveland Public Access UN*X, Cleveland, Oh Lines: 28 As quoted from <2098@ncr-sd.SanDiego.NCR.COM> by laman@ncr-sd.SanDiego.NCR.COM (Mike Laman): +--------------- | In article <303@wsccs.UUCP> terry@wsccs.UUCP (terry) writes: | > Instead of a fork, a popen( "program", "r") is done, where the | > purpose of the child is to hang on the read and signal the parent | > (via a signal, semaphore, or shared memory) when the read completes, | ^^^^^^ | BE VERY CAREFUL! On System V and V.2 this won't work if the | parent process gets too far behind the reading child process. > (details of System V "unsafe" signals deleted) | also consider what may happen if the system gets busy. Remember that | if you lose ONE signal, your parent will be "forever" out of sync, | unless you make some arrangement in the parent to make sure at | certain times that you have gotten all of the input. But then that | reverts you back to what you were trying to get around. +--------------- NDELAY-read a buffer-full when you get the signal. How likely is the parent to be behind by more than 256 characters? More than 1024? Normally, NDELAY means the system takes a performance hit, but if you read only when signalled then you are guaranteed AT LEAST one character waiting. (...this sounds like faking SIGIO....) Anyway, your NDELAY read will return the actual number of characters read, and the parent can then process them appropriately. And the overhead of one NDELAY read of 1024 characters is no greater than the overhead of a standard NDELAY read of one character. -- Brandon S. Allbery, moderator of comp.sources.misc {well!hoptoad,uunet!hnsurg3,cbosgd,sun!mandrill}!ncoast!allbery