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).