Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: improve checkptycmd



On Mon, Jul 6, 2026 at 7:39 PM Jun T <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
>
> With this patch (commit 4b4ebcca) lots of tests fails on macOS
> (probably all the tests that use zpty). It seems reading from zpty
> returns nothing.
>
> On macOS, HAVE_POLL is not defined because zsh_system.h:374-381 has
>
> #if defined(__APPLE__) && defined(HAVE_SELECT)
> /*
>  * Prefer select() to poll() on MacOS X since poll() is known
>  * to be problematic in 10.4
>  */
> #undef HAVE_POLL
> #undef HAVE_POLL_H
> #endif
>
>
> In funcion checkptycmd(), at zpty.c:576
>         ret = select(cmd->fd + 1, (SELECT_ARG_2_T) &fds, NULL, NULL, &tv);
> returns ret=1 (and select_ret is set to 1), but at line 583
>     if (ioctl(cmd->fd, FIONREAD, (char *) &val) == 0 && val > 0)
> returns val = 0, and the pty is closed at line 588.
>
> I don't know select()/ioctl() are working as expected or not.
>
> But, if I remove the lines 374-381 in zsh_system.h, i.e., if we use poll()
> also on macOS, then all the test pass, at least on the latest macOS (Sequoia).
>
> Version 10.4 mentioned in the comment is Tiger, which is released in 2005,
> and not supported since 2009, probably.
>
> If there are someone who have older macOS, please test by removing the
> lines 374-381 in zsh_system.h.

Hmm, I didn't look at the code again, but the idea was that even if
one of these things is not defined, the code should still work at
least as well as before. I'll take another look at it a bit later.

-- 
Mikael Magnusson




Messages sorted by: Reverse Date, Date, Thread, Author