Hello,
I find that the file descriptor leaks when I execute the command pvs in bash
5.2, The abnormal scenario is similar to the bug which reported by
http://lists.gnu.org/archive/html/bug-bash/2017-01/msg00026.html
When I execute pvs in the terminal opened through xshell??it??s ok
PV VG Fmt Attr PSize PFree
/dev/sda2 euleros lvm2 a-- <126.00g 0
But when I execute pvs in the terminal opened through vscode??use Remote-SHH to
connect linux??, the File descriptor was leaked
File descriptor 19 (/dev/ptmx) leaked on pvs invocation. Parent PID 3789:
/usr/bin/bash
File descriptor 20 (/dev/ptmx) leaked on pvs invocation. Parent PID 3789:
/usr/bin/bash
File descriptor 21 (/dev/ptmx) leaked on pvs invocation. Parent PID 3789:
/usr/bin/bash
File descriptor 99
(/root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/vscode-remote-lock.root.899d46d82c4c95423fb7e10e68eba52050e30ba3)
leaked on pvs invocation. Parent PID 3789: /usr/bin/bash
PV VG Fmt Attr PSize PFree
/dev/sda2 euleros lvm2 a-- <126.00g 0
I found that the leaked file descriptor was created in subst.c
/* Pipe the output of executing STRING into the current shell. */
if (pipe(fildes) < 0)
{
sys_error("%s", _("cannot make pipe for command substitution"));
goto error_exit;
}
add it leaked in
if (--bufn <= 0)
{
SET_CLOSE_ON_EXEC(fd);
bufn = zread(fd, buf, sizeof(buf));
if (bufn <= 0)
break;
bufp = buf;
}
I try to add SET_CLOSE_ON_EXEC (fd) before zread, but it doesn't seem to work.