diff --git a/docs/changelog.rst b/docs/changelog.rst index 2e6a940c4..897183902 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -439,6 +439,9 @@ Detailed list of changes spaces, a duplicate path when dropping items from Apple Mail and a memory leak (:iss:`10708`, :iss:`10581`, :iss:`10628`, :iss:`10673`) +- macOS: Fix kitty freezing when opening a new window while another entry in + :file:`/dev` is stuck (:iss:`10741`) + 0.49.2 [2026-10-01] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/child.c b/kitty/child.c index 3bf39fb01..77b6f89dc 100644 --- a/kitty/child.c +++ b/kitty/child.c @@ -107,7 +107,16 @@ spawn(PyObject *self UNUSED, PyObject *args) { &pass_fds)) return NULL; char name[2048] = {0}; - if (ttyname_r(slave, name, sizeof(name) - 1) != 0) { +#ifdef __APPLE__ + // ttyname_r() on macOS calls lstat() on every entry in /dev until it finds + // the pty, so a single stuck entry can hang it. ptsname_r() gets the name + // from the master with an ioctl() instead. + // See https://github.com/kovidgoyal/kitty/issues/10741 + int ret = ptsname_r(master, name, sizeof(name) - 1); +#else + int ret = ttyname_r(slave, name, sizeof(name) - 1); +#endif + if (ret != 0) { PyErr_SetFromErrno(PyExc_OSError); return NULL; }