bug-bash
[Top][All Lists]
Advanced

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

Re: Leak in BASH "named" file descriptors?


From: Mathieu Patenaude
Subject: Re: Leak in BASH "named" file descriptors?
Date: Thu, 28 Jan 2016 13:44:34 -0500

Chet, thanks for the clarification

So the answer is - this is by design, i.e. as soon as you use a variable for the FD, you are responsible of managing it for the duration of its life.

Knowing this makes it much more "reliable" to use ;-)  I also could not find the relevant info on the list / web, so I was really starting to think this was a bug.  Maybe the "REDIRECTION" section of the BASH man page would be a good spot to mention this?

Thanks to all for answering my questions,

Math.


On Thu, Jan 28, 2016 at 1:33 PM, Chet Ramey <chet.ramey@case.edu> wrote:
On 1/27/16 1:18 PM, Mathieu Patenaude wrote:
> Hi,
>
> When using "named" file descriptors inside a function, the file descriptors
> are not automatically un-linked when the function returns, but when using
> regular "numbered" file descriptors they are automatically "destroyed".

Yes.  That's the intent.  The idea is that if you assign a variable, you
have a `handle' on the file descriptor and can manage it yourself.  It's
closer to how open(2) works: the system selects a descriptor and tells you
what it is, and it's up to you to track it from there.

In that sense, variables assigned by redirections are similar to how
`exec' makes redirections persist beyond a single command.

(I thought this had come up before, but I couldn't find that particular
discussion.)

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


reply via email to

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