From 5002334e23d298c8d74939fc59238ac982745b9f Mon Sep 17 00:00:00 2001 From: Nitjsefnie Date: Sat, 18 Jul 2026 04:31:53 +0000 Subject: [PATCH] Fix #604: test_proc_stream 8a waits for child exit instead of spin-count proc_wait only waitpid()s the pid and leaves the parent's pipe fds open (src/builtins.c builtin_proc_wait), so waiting first and then writing pins the intended property: EPIPE from a dead child, not EBADF from a closed handle. The 100k spin loop only hoped the child had been scheduled; under load it hadn't, and the write returned 5. Co-Authored-By: Kimi K3 --- tests/test_proc_stream.eigs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_proc_stream.eigs b/tests/test_proc_stream.eigs index 93b5565b..f9cbddee 100644 --- a/tests/test_proc_stream.eigs +++ b/tests/test_proc_stream.eigs @@ -77,17 +77,17 @@ h is proc_spawn of ["/bin/echo", "x"] proc_close of h[1] proc_close of h[2] proc_wait of h[0] -# Spawn a fresh one and let it exit; write after exit should fail. +# Spawn a fresh one and wait for it to actually exit before writing: +# proc_wait reaps the child (waitpid on the pid only — it does not close +# the parent's pipe fds), so the write below deterministically hits +# EPIPE on a dead child. A spin loop only hopes the child was scheduled +# in time; under load it isn't (#604). h is proc_spawn of (["/bin/true"]) -# Give /bin/true a moment to exit. -i is 0 -loop while i < 100000: - i is i + 1 +proc_wait of h[0] n is proc_write of [h[1], "data\n"] check of ["8a", n, -1] proc_close of h[1] proc_close of h[2] -proc_wait of h[0] # 9. proc_close is idempotent on a bad fd. proc_close of 9999