Close slave on fork error to prevent pty fd leak.

CID: 978209
This commit is contained in:
imp 2017-12-28 05:33:59 +00:00
parent 1ccd04128b
commit f079001a1d

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);
}