LibC: openpty error handling update

This commit is contained in:
David Carlier 2021-05-30 06:50:42 +01:00 committed by Andreas Kling
parent 755393e684
commit 594dfaadb9

View file

@ -56,12 +56,22 @@ int openpty(int* amaster, int* aslave, char* name, const struct termios* termp,
return -1;
}
if (termp) {
// FIXME: error handling
tcsetattr(*aslave, TCSAFLUSH, termp);
if (tcsetattr(*aslave, TCSAFLUSH, termp) == -1) {
int error = errno;
close(*aslave);
close(*amaster);
errno = error;
return -1;
}
}
if (winp) {
// FIXME: error handling
ioctl(*aslave, TIOCGWINSZ, winp);
if (ioctl(*aslave, TIOCGWINSZ, winp) == -1) {
int error = errno;
close(*aslave);
close(*amaster);
errno = error;
return -1;
}
}
dbgln("openpty, master={}, slave={}, tty_name={}", *amaster, *aslave, tty_name);