mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-18 06:04:49 +00:00
macOS: Fix kitty freezing when opening a window while a /dev entry is stuck
On macOS, ttyname_r() calls devname_r(), which lstat()s every entry in /dev until one matches. New ptys are appended to /dev, so naming the pty of a new window looks up every older entry, and one stuck entry blocks spawn() on the main thread with the GIL held, freezing kitty. ptsname_r() on the master returns the same name with one ioctl() and a stat() of that single path. Other platforms keep ttyname_r(), which does not walk /dev there in the normal case. Fixes #10741
This commit is contained in:
parent
debcde56c0
commit
b2087a7b42
2 changed files with 13 additions and 1 deletions
|
|
@ -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]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue