[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The primitiveness of pipe
> Imagine we had such a primitive, let's call it $&pipe2 so we don't
> confuse it with the current pipe primitive. pipe2 would open a pipe
> and return the two resulting file descriptors. It would also do the
> necessary internal book-keeping for the file descriptors.
> Then we should be able to rewrite %pipe in terms of $&pipe2 and
> $&background, at least in principle. We may or may not want to do so.
getting everything right w.r.t. closing the pipe before waiting is
a little hard; i'm not sure that you wouldn't need some additional
hackery in wait, but it could probably be made to work.
> But we could also do all sorts of things you can usually not do in
> other shells, like open a file descriptor in the current shell which
> is a pipe into (or from) a process running in the background.
that's already pretty easy to do if you have /dev/fd, and is
easily simulated in most cases with the <{} and >{} implementations
using /tmp. one case which does not work w/o /dev/fd but i like
very much is
; exec {%open 0 <{echo foo; echo bar} {}}
; cat
foo
bar
;
paul