bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: eval doesn't close file descriptor?


From: Ken Irving
Subject: Re: eval doesn't close file descriptor?
Date: Tue, 12 Feb 2013 13:03:06 -0900
User-agent: Mutt/1.5.20 (2009-06-14)

On Tue, Feb 12, 2013 at 04:22:08PM -0500, Matei David wrote:
> Generally speaking, it took me quite some time to figure out how to
> properly create a "double pipe" without using any intermediate files or
> fifos. The concept is very easy: in -> tee -> two parallel, independent
> pipes -> join -> out. A first complication is the limited pipe capacity,
> and the possibility of one side getting stuck if the other stops pulling in
> data. I then wrote a cat-like program which doesn't block on stdout, but
> keeps reading stdin, buffering in as much data as needed. I used it at the
> very end of either pipe. But then I had to create the actual processes, and
> then I stumbled upon all these issues with coproc and file descriptors. You
> leave the wrong one open and the thing gets stuck... I wish there was a
> howto on this subject.

I really like to see these threads that poke at the edges of things
in bash, providing a great learning opportunity for lurkers like me.
But that said, perhaps what you're trying to so might be handled easily
by socat; from http://www.dest-unreach.org/socat/doc/README:

    socat is a relay for bidirectional data transfer between two
    independent data channels. Each of these data channels may be a file,
    pipe, device..., a socket..., a file descriptor (stdin etc.) ...

Just a thought.

Ken



reply via email to

[Prev in Thread] Current Thread [Next in Thread]