Subject: bug#78946: 30.1; accept-process-output not allowed in threads on macOS

From: Alan Third <[email-masked]>
Date: Fri, 4 Jul 2025 21:20:07 +0100

On Fri, Jul 04, 2025 at 01:46:19PM +0200, Robert Pluim wrote:
> >>>>> On Thu, 03 Jul 2025 16:00:23 -0700, John Wiegley <[email-masked]> said:
> 
> >>>>> Robert Pluim <[email-masked]> writes:
>     >> John, does it help if you stick something like
> 
>     >> if ([[NSThread currentThread] isMainThread])
>     >> {
>     >> }
> 
>     >> around the
> 
>     >> [NSApp run];
> 
>     >> in `ns_select_1'?
> 
>     John> Hi Robert,
> 
>     John> With this change, I’m able to run the tests successfully 10,000 times in my
>     John> interactive Emacs on macOS.
> 
> Thatʼs encouraging. Alan, does this change make sense? (Iʼve swapped
> out what little I know about the macOS event loop 😀)

Not really... The whole thing is a mess. The return here:

  if (![NSThread isMainThread]
      || (timeout && timeout->tv_sec == 0 && timeout->tv_nsec == 0))
    thread_select (pselect, nfds, readfds, writefds,
		   exceptfds, timeout, sigmask);

Was removed and I don't think it should have been, but it was to
prevent freezes, apparently... I don't know or recall how this helped,
it looks completely wrong to me. Surely that thread_select call should
return a result?

Sorry, this hasn't been much help.
-- 
Alan Third