Close slave on fork error to prevent pty fd leak.

CID: 978209
This commit is contained in:
Warner Losh 2017-12-28 05:33:59 +00:00
parent 076950009f
commit 7e8fba7889

View File

@ -101,12 +101,13 @@ forkpty(int *amaster, char *name, struct termios *termp, struct winsize *winp)
return (-1);
switch (pid = fork()) {
case -1:
(void)close(slave);
return (-1);
case 0:
/*
* child
*/
(void) close(master);
(void)close(master);
login_tty(slave);
return (0);
}