[TAG] 2c tip: filtering in-place

Jay R. Ashworth jra at baylink.com
Mon Mar 22 18:14:32 MSK 2004


On Sun, Mar 21, 2004 at 10:21:27PM -0500, Ben Okopnik wrote:
> > Cause of what happens if the thing is interrupted in the middle, among
> > other thiings.
>  
> Much like what happens with Kapil's solution if it's interrupted during
> the first pipe, with additional complications if it's interrupted during
> the second.

Actually, if Kapil's solution is interrupted in the middle, you have a
half processed input file.  At least you still *have* some file.

> > > > Doesn't that still depend on order of evaluation by the shell?  Is that
> > > > defined?
> > > 
> > > Well, yes....
> > > 
> > > 1. buffer < foo
> > > 2. | filer is acted upon
> > > 3. Resultant output to file
> > 
> > Well, not necessarily.
> > 
> > A shell could (un)reasonably decide to evaluate the output redirection
> > (ie: stomp on the file) before the buffer program can read it.  At
> > best, it might be a race condition between the two sides of the pipe.
>  
> Uh, not any shell that contains a _working_ implementation of IPC. One
> that's broken, certainly. Chances are that if time ran backwards, it
> probably wouldn't work too well either...

Every shell programing I've read in 20 years warns againts that
construct, precisely because most shells *will* set up the redirect
first and stomp the output file.  As for the pipeline, I believe that
most shells exec the last component first.  Maybe bash has changed
that; I remember a warning about it in the Bourne book.

> > I don't think, intuitively, that it's at all reliable, where as I think
> > the dd approach probably is.
> 
> Please state the mean and the average probabilities and the relevant
> confidence levels for the accuracy of your intuitive approach. The data
> generated in the course of your study may or may not be used as grounds
> for questioning during your exam. :)

Ok, I've taked the rifle out of the box under my chair and assembled
it.  Where's the ammo?

Cheers,
-- jra
-- 
Jay R. Ashworth                                                jra at baylink.com
Member of the Technical Staff     Baylink                             RFC 2100
The Suncoast Freenet         The Things I Think
Tampa Bay, Florida        http://baylink.pitas.com             +1 727 647 1274

        "They had engineers in my day, too."  -- Perry Vance Nelson




More information about the TAG mailing list