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: Greg Wooledge
Subject: Re: Leak in BASH "named" file descriptors?
Date: Thu, 28 Jan 2016 08:09:41 -0500
User-agent: Mutt/1.4.2.3i

On Wed, Jan 27, 2016 at 01:18:11PM -0500, Mathieu Patenaude wrote:
> 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".

Could not reproduce in an interactive shell, on bash 4.3.30 (Debian).

$ f() { local fd; exec {fd}</dev/null; }
$ f
$ g() { exec 9</dev/null; }
$ g
$ lsof -p $$
...
bash    931 wooledg    0u   CHR  136,0      0t0       3 /dev/pts/0
bash    931 wooledg    1u   CHR  136,0      0t0       3 /dev/pts/0
bash    931 wooledg    2u   CHR  136,0      0t0       3 /dev/pts/0
bash    931 wooledg    9r   CHR    1,3      0t0    1028 /dev/null
bash    931 wooledg   10r   CHR    1,3      0t0    1028 /dev/null
bash    931 wooledg  255u   CHR  136,0      0t0       3 /dev/pts/0

I actually ran the lsof multiple times, in between the calls to f and g.
FD 10 was opened by f (and kept open), and FD 9 was of course opened by g
(and kept open).



reply via email to

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