Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 05 Nov 2008 23:10:36 +0400
From:      rihad <rihad@mail.ru>
To:        Nate Eldredge <neldredge@math.ucsd.edu>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Asynchronous pipe I/O
Message-ID:  <4911EFAC.7090909@mail.ru>
In-Reply-To: <Pine.GSO.4.64.0811050857000.1597@zeno.ucsd.edu>
References:  <4911A23B.7050104@mail.ru> <Pine.GSO.4.64.0811050857000.1597@zeno.ucsd.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
Nate Eldredge wrote:
> On Wed, 5 Nov 2008, rihad wrote:
> 
>> Imagine this shell pipeline:
>>
>> sh prog1 | sh prog2
>>
>>
>> As given above, prog1 blocks if prog2 hasn't yet read previously written
>> data (actually, newline separated commands) or is busy. What I want is
>> for prog1 to never block:
>>
>> sh prog1 | buffer | sh prog2
> 
> [and misc/buffer is unsuitable]
> 
> I found an old piece of code laying around that I wrote for this 
> purpose. Looking at it, I can see a number of inefficiencies, but it 
> might do in a pinch.  You're welcome to use it; I hereby release it to 
> the public domain.
> 
> Another hack that you could use, if you don't mind storing the buffer on 
> disk rather than memory, is
> 
> sh prog1 > tmpfile &
> tail -f -c +0 tmpfile | sh prog2
> 
Thanks, but I was looking for how to get some port do that useful 
functionality for me. Strange as it is, there doesn't seem to be such a 
tool handy, despite the "small tool doing one thing good" philosophy of 
Unix! It's invaluable for optimizing certain tasks and isn't coupled to 
anything: as generic as could be. Perhaps I should also email buffer's 
author <jonny@jonny.eng.br> for his opinion, and ask him why -p 0 
(default) doesn't do the Right Thing.

> Here's my program.
Thanks again, I'm sure I'll use your code if I can't get the port 
version to work.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4911EFAC.7090909>