Advanced shell scripting question :-)

Steven W. Orr steveo at syslang.net
Thu Sep 5 15:22:36 EDT 2002


On 5 Sep 2002, Kevin D. Clark wrote:

=>
=>"Steven W. Orr" <steveo at syslang.net> writes:
=>
=>> This is actually even closer to what I want. The problem is now strictly 
=>> that the output into both is not coming out in the same order as what 
=>> appears on the screen.
=>
=>...
=>
=>> It works great, except that the order is not being preserved. :-(
=>
=>Actually, the order is being preserved -- I guarantee it.  If you put
=>stuff into a pipe in a certain order, I guarantee to you that this
=>stuff will come out the other side in the same order.
=>
=>Your problem has to do with stdio buffering, the fact that the stdio
=>library does different things with this buffering when the output is
=>connected to a terminal versus something else (fully-buffered versus
=>line buffering), and the whim of the kernel and the scheduler.
=>
=>Your original question never specified that you wanted this "ordering"
=>(this is a nebulous term in these circumstances) to be preserved.  Now
=>that you've placed this additional constraint on the problem, the
=>solution becomes a lot trickier.
Now we're gettin' somewhere. :-)

You do understand that the order through the pipe does get preserved. The 
problem is that the order coming out is vastly different than the order 
that appears on the console. By all appearances, the console output *is* 
the *correct* output. So if the order *is* being preserved, how can the 
content of the BOTH file be different than that appearing on the console?

I was suspecting that this is somehow STREAMS related, but the problem is 
duplicated on both Linux and Solaris (which is STREAMS based). 

I can live with the problem not having a solution; I just really want to 
know *why*. :-(

-- 
-Time flies like the wind. Fruit flies like a banana. Stranger things have -
-happened but none stranger than this. Does your driver's license say Organ
-Donor?Black holes are where God divided by zero. Listen to me! We are all-
-individuals! What if this weren't a hypothetical question? steveo at syslang.net




More information about the gnhlug-discuss mailing list