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

Re: W02jobs.ztst: huge delay if output is piped (macOS)



On Fri, Jul 3, 2026 at 7:27 PM Jun T <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
>
> On macOS (using the current git master: ref: workers/54751)
>
> % time make TESTNUM=W02 check
> make TESTNUM=W02 check  0.52s user 0.61s system 42% cpu 2.674 total
>
> % time make TESTNUM=W02 check | cat
> make TESTNUM=W02 check  0.52s user 0.61s system 41% cpu 2.703 total
> cat  0.00s user 0.00s system 0% cpu 1:41.67 total
>
> (cat takes about 100 sec longer than make)
>
> The 'sleep 100' in the last hunk of W22jobs.ztst is not terminated (why?)
> and keeps fd=12 for the pipe, and 'cat' is waiting for EOF from the pipe.
> I think this fd=12 is inherited from ztst.zsh; it calls ZTST_execchunk at
> line 506 with redirection, and fd=1 (the pipe) is saved in fd=12 (but why
> this fd need be inherited by 'sleep'?).
>
> The 100-sec delay does not happen if line 10 of W02jobs.ztst
>       zpty -w zsh 'alias sleep="sleep </dev/null >/dev/null 2>&1"'
> is commented out. 'sleep 100' is terminated in this case, but lots
> of 'sleep {2,3,4}' remain and causes a few-sec delay. This short delay
> also happens on Linux.
>
> It would be nice if we can cleanly terminate all the 'sleep', but if that
> is not easy we can just change 'sleep 100' to, say, 'sleep 3'.
>
> # sorry if this issue has been already discussed; I couldn't follow ML
> # for about two months.

We added the alias because on Linux, without that alias, the test
always takes a long time. Actually the problem you point out happens
on Linux too, but it's less noticable because the test itself doesn't
hang, rather it is make that hangs:
% make TESTNUM=W02 check | cat
... test output ...
***********************************************
1 successful test script, 0 failures, 0 skipped
***********************************************
make[1]: Leaving directory '/.../zsh/Test'
[this is where the 100 second delay happens]

But without the alias, the test itself hangs for about 1-2 minutes on
Linux (before the "W02jobs.ztst: all tests successful." line is
printed), because the pty isn't destroyed until all processes with
references to it exit. I have no immediate explanation for why cat
waits for these processes though. Without the alias, IIRC OSX will
send a HUP to the sleeps when we close the pty, so that's why cat
doesn't hang in that case. I agree that there doesn't seem to be a
reason that this sleep should be so long, though, and when running the
full test suite, any single digit sleep will have finished by the time
we get to the end.

-- 
Mikael Magnusson




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