On Mon, Dec 07, 2009 at 12:24:05PM +0000, roger peppe wrote:
> if you wanted it, an "fd join" driver could be simply
> implemented in a similar way:
> 
> bind '#j4.5' /mnt/joined
> open /mnt/joined/data to get a (read-only) fd that satisfies reads from fd 4
> until eof, then fd 5.

That's not what I meant by joining two fds.

I meant for example if a process is reading from its stdin a open file 'A' and
writing to stdout the input of a pipe 'B', rather than looping and forwarding
data it may simply "join" these two fds, and exit.  The OS will then do what is
necessary to make sure the data can travel from A to B (and/or vice versa) with
the minimum effort needed.

Supposing another process 'foo' is reading the other end of the pipe 'C', the
OS will simply remove the pipe 'B-C' entirely, and reroute 'foo's stdin to come
directly from 'A'.  In other circumstances the OS might need to effectively
exec 'cat' (or a 2-way socket-cat) to take over the task of copying data, but
often it will be able to remove a pipe, reducing the amount of unnecessary
copying that will take place.

Where I have said "stdin" I mean the fds not stdio / buffered IO FILEs.

I hope I've cleared up what I meant now, seems I'm not very good at explaining
it.

Sam

Reply via email to