diff options
author | David Carlier <devnexen@gmail.com> | 2021-05-30 06:50:42 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-30 08:41:17 +0200 |
commit | 594dfaadb90276582741dcf69e9836cb83ebeae8 (patch) | |
tree | 043a995534b5c766ed5869b2b1e8792f935b7228 /Userland/Libraries/LibC | |
parent | 755393e684268b8ee1c1f72b6a705e99827836b5 (diff) | |
download | serenity-594dfaadb90276582741dcf69e9836cb83ebeae8.zip |
LibC: openpty error handling update
Diffstat (limited to 'Userland/Libraries/LibC')
-rw-r--r-- | Userland/Libraries/LibC/pty.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
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); |