[comp.unix.wizards] Unbuffered pipe

gavin@krypton.asd.sgi.com (Gavin Bell) (02/08/91)

Is there any way to turn off the PIPE_MAX-long buffer used for pipes?
I need simple unbuffered, one-way communication.

Details on what I'm trying to do:

Essentially, I have the following situation:

filter1 < file_of_data | filter2

... where filter1 understands some of the data in in file_of_data to
be "present this text to the user now, so they know what is going on"
and filter2 understands the rest of the data (which is things like
"Pause for 3 seconds; now display this anti-aliased wireframe
airplane... etc").

Pipes are perfect for this, except that they are buffered, so filter1
is not synchronized with filter2.

I would prefer a portable (at least SYSV), non-hack solution.
--
--gavin     (gavin@sgi.com,  (415)335-1024)

tchrist@convex.COM (Tom Christiansen) (02/08/91)

From the keyboard of gavin@krypton.asd.sgi.com (Gavin Bell):
:Is there any way to turn off the PIPE_MAX-long buffer used for pipes?
:I need simple unbuffered, one-way communication.
:
:Details on what I'm trying to do:
:
:Essentially, I have the following situation:
:
:filter1 < file_of_data | filter2

If you have the code for filter1, just unbuffer stdout, or fflush it at
will.  If you don't, there's little you can do, as the buffering is
occurring in the stdio library contained in the program.  Unbelievably
grody hacks mucking with the FILE struct using some binary patch not
withstanding, nor suggested.

--tom
--
 "All things are possible, but not all expedient."  (in life, UNIX, and perl)

david@talgras.UUCP (David Hoopes) (02/08/91)

In article <1991Feb07.211021.8761@convex.com> tchrist@convex.COM (Tom Christiansen) writes:
>From the keyboard of gavin@krypton.asd.sgi.com (Gavin Bell):
>:Is there any way to turn off the PIPE_MAX-long buffer used for pipes?
>:I need simple unbuffered, one-way communication.
>: [ stuff deleted ]
>
>If you have the code for filter1, just unbuffer stdout, or fflush it at
                                        ^^^^^^^^^^^^^^^
How does one go about unbuffering stdout?




-- 
---------------------------------------------------------------------
David Hoopes                              Tallgras Technologies Inc. 
uunet!talgras!david                       11100 W 82nd St.          
Voice: (913) 492-6002 x323                Lenexa, Ks  66214        

gwyn@smoke.brl.mil (Doug Gwyn) (02/09/91)

In article <41@talgras.UUCP> david@talgras.UUCP (David Hoopes) writes:
>How does one go about unbuffering stdout?

Use setbuf() with a null buffer pointer argument.

This question should have been posted to comp.unix.questions.

allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) (02/16/91)

As quoted from <1991Feb08.151307.3160@convex.com> by tchrist@convex.COM (Tom Christiansen):
+---------------
| It seems inappropriate to use comp.unix.wizards as an AI interface to TFM.
+---------------

Your intelligence is artificial?  :-)

++Brandon
-- 
Me: Brandon S. Allbery			    VHF/UHF: KB8JRR on 220, 2m, 440
Internet: allbery@NCoast.ORG		    Packet: KB8JRR @ WA8BXN
America OnLine: KB8JRR			    AMPR: KB8JRR.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery    Delphi: ALLBERY