1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:17:35 +00:00

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; return -1;
} }
if (termp) { if (termp) {
// FIXME: error handling if (tcsetattr(*aslave, TCSAFLUSH, termp) == -1) {
tcsetattr(*aslave, TCSAFLUSH, termp); int error = errno;
close(*aslave);
close(*amaster);
errno = error;
return -1;
}
} }
if (winp) { if (winp) {
// FIXME: error handling if (ioctl(*aslave, TIOCGWINSZ, winp) == -1) {
ioctl(*aslave, TIOCGWINSZ, winp); int error = errno;
close(*aslave);
close(*amaster);
errno = error;
return -1;
}
} }
dbgln("openpty, master={}, slave={}, tty_name={}", *amaster, *aslave, tty_name); dbgln("openpty, master={}, slave={}, tty_name={}", *amaster, *aslave, tty_name);