bug-bash
[Top][All Lists]
Advanced

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

Re: process substitution and trailing file descriptors


From: Greg Wooledge
Subject: Re: process substitution and trailing file descriptors
Date: Thu, 11 Feb 2010 15:29:24 -0500
User-agent: Mutt/1.4.2.3i

On Thu, Feb 11, 2010 at 03:04:30AM -0800, Ian wrote:
>  The manual suggests I could move and close file descriptors with
> 
>  [n]>&digit-
> 
>  but I would need the equivalent of
> 
>  command1 >&>(...)-
> 
>  Digit might very well mean (just a) digit but here the process
> substitution, of course, is replaced with /dev/fd/63, say, certainly
> not a digit.

Some older versions of bash had issues with FDs higher than 9, but those
bugs have certainly been fixed by at least version 4.0.  If you aren't
stuck supporting old bashes, then exec 63>&- should work fine, if you
happen to know that 63 is the correct FD number.

Also bear in mind that not all platforms implement >() using /dev/fd/*.
On some systems it's done with a FIFO.

But I think these are minor details which don't bear directly on your
real question.

>  Basically, by mixing IO redirection and process substitution I'm left
> with a trailing file descriptor which can cause scripts to hang around
> despite any subsequent redirection of stdout/stderr best practices.
> There's no mechanism to discover these new file descriptors and they
> are not closed on exec.
> 
>  Is there any hope for me?

When the shortcuts are too short, you need to fall back to the original
tools.  In this case, >() is really just a shortcut for "create a FIFO,
and open it".  Doing so by hand should give you the manual control you
need.  At the very least, you can tell bash which FD number to use when
you open the FIFO.




reply via email to

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