From 594dfaadb90276582741dcf69e9836cb83ebeae8 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 30 May 2021 06:50:42 +0100 Subject: LibC: openpty error handling update --- Userland/Libraries/LibC/pty.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'Userland/Libraries/LibC') diff --git a/Userland/Libraries/LibC/pty.cpp b/Userland/Libraries/LibC/pty.cpp index 19706951a6..88e2245cdd 100644 --- a/Userland/Libraries/LibC/pty.cpp +++ b/Userland/Libraries/LibC/pty.cpp @@ -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); -- cgit v1.2.3