On Mon, Oct 12, 2009 at 1:14 PM, Ralf Goertz
<r_goe...@usenet.arcornews.de>wrote:

> Hi,
>
> is it possible to have a process substitution with both input and output
> redirection? So far I use the following work-around
>
> > cat parentprocess.sh:
> #!/bin/bash
> mkfifo fifo 2>/dev/null
> exec 5> >(./subprocess.sh > fifo)
> exec 6< <(cat < fifo)
> echo input to subprocess 1>&5
> echo done sending input
> sleep 1
> while read -u 6 ; do
> echo parent process read: $REPLY
> done
> exec 5>&-
> echo about to exit parent process rm fifo
>
> > cat subprocess.sh:
> #!/bin/bash
> echo subprocess start
> read
> sleep 1
> echo read: $REPLY
> echo subprocess end
> >
>
> Is there another way to do that, something like fork, which wouldn't use
> a named pipe explicitely?
>

in bash4 you can use a coproc, see:
http://bash-hackers.org/wiki/doku.php/syntax/keywords/coproc

Reply via email to