help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] stdout and stderr to two different process substitutions


From: Greg Wooledge
Subject: Re: [Help-bash] stdout and stderr to two different process substitutions
Date: Wed, 25 Jan 2012 14:04:36 -0500
User-agent: Mutt/1.4.2.3i

On Wed, Jan 25, 2012 at 12:36:24PM -0600, Peng Yu wrote:
> OK. To summarize concisely, it appears to be that there are only
> "global" stdout and stderr, but stdin is local.

No.  That is not a fair summary at all.

Every process has its *own* FDs -- stdin, stdout, stderr, plus any that
it opens.  These can be separate, or they can be the same.

> foo  > >(gzip > xx.gz) 2> >(tee yy 1>&2)

1) gzip is run in the background.  Its stdout goes to xx.gz.  Its input
   is connected to a pipe (call it "A").

2) foo's output is redirected to pipe A.

3) tee is run in the background.  Its stdout is redirected to its stderr,
   which it inherited from foo.  Its input is connected to pipe "B".

4) foo's stderr is redirected to pipe B.

I really can't explain it any more clearly than that.  Those 4 things
occur *in that order*.  It cannot be simplified any more than that
without misrepresenting what's occurring in the software.

There is certainly no "global stdout".  FDs are inherited, but then they
can be closed or redirected.



reply via email to

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