Avoid reusing open file descriptor to make it easier to pinpoint Coverity CID 1164479 resource leak.

This commit is contained in:
Petter Reinholdtsen 2014-02-07 09:50:14 +00:00
parent 6ba8311144
commit cc3a4e2f9e

View File

@ -1170,15 +1170,16 @@ pid_t spawn(CHILD *ch, int *res)
/* Set ioctl settings to default ones */ /* Set ioctl settings to default ones */
console_stty(); console_stty();
} else { } else { /* parent */
int fd;
setsid(); setsid();
if ((f = console_open(O_RDWR|O_NOCTTY)) < 0) { if ((fd = console_open(O_RDWR|O_NOCTTY)) < 0) {
initlog(L_VB, "open(%s): %s", console_dev, initlog(L_VB, "open(%s): %s", console_dev,
strerror(errno)); strerror(errno));
f = open("/dev/null", O_RDWR); fd = open("/dev/null", O_RDWR);
} }
dup(f); dup(fd);
dup(f); dup(fd);
} }
/* /*