bug-bash
[Top][All Lists]
Advanced

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

Re: process substitution


From: Pierre Gaston
Subject: Re: process substitution
Date: Thu, 15 Oct 2009 08:54:58 +0300

On Mon, Oct 12, 2009 at 1:14 PM, Ralf Goertz
<address@hidden>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

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