From ac686a47c13e4ca892f43b4216154c2c140a2787 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Sep 2018 14:29:10 +0530 Subject: [PATCH] Fail early when opening tty fails --- kitty/data-types.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kitty/data-types.c b/kitty/data-types.c index 92bad6761..eca5a315b 100644 --- a/kitty/data-types.c +++ b/kitty/data-types.c @@ -126,6 +126,7 @@ open_tty(PyObject *self UNUSED, PyObject *args) { if (!read_with_timeout) flags |= O_NONBLOCK; static char ctty[L_ctermid+1]; int fd = open(ctermid(ctty), flags); + if (fd == -1) { PyErr_SetFromErrno(PyExc_OSError); return NULL; } struct termios *termios_p = calloc(1, sizeof(struct termios)); if (!termios_p) return PyErr_NoMemory(); if (tcgetattr(fd, termios_p) != 0) { free(termios_p); PyErr_SetFromErrno(PyExc_OSError); return NULL; }