keypressed()--- and the answer is:

Brandon Allbery allbery at ncoast.UUCP
Thu Mar 24 08:21:29 AEST 1988


As quoted from <2098 at ncr-sd.SanDiego.NCR.COM> by laman at ncr-sd.SanDiego.NCR.COM (Mike Laman):
+---------------
| In article <303 at wsccs.UUCP> terry at 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



More information about the Comp.unix.wizards mailing list