Repository navigation
Hold native env test children until their output is read - #734
Merged
Merged
Conversation
On macOS, ptsclose gives the PTY master 0.6 s after the child's last close to drain queued output and then discards it. The env tests ran commands that print and exit within a millisecond, so any reader-thread stall past that deadline on a loaded CI runner left the terminal empty with exit status 0. The POSIX env commands now print their marker and block on read, so a child cannot exit before the reader has its output. The native process helper releases a held command with a newline once the marker is on screen; the other callers only wait for the marker and let test teardown kill the child.
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the macOS-only CI flake where
ghostel-test-native-process-env-first-entry-winsandghostel-test-native-process-adds-display-for-graphical-framefail with "produced no output (exit status 0)" after ~0.6 s.Root cause
xnu's
ptsclose(bsd/kern/tty_dev.c,FIX_VSX_HANG) forces the tty drain timeout to 60 ticks = 0.6 s at hz=100. When the child's last replica close happens,ttywaitgives the master reader 0.6 s to consume queued output; past that,ttyflushdiscards it and the master sees only POLLHUP + EOF./usr/bin/envprints and exits within a millisecond, so any reader-thread stall past 0.6 s on a loaded runner loses the whole output. Reproduced with a standalone PTY script: parent closes the replica, stalls, reads → the child's exit blocks exactly 0.6 s, then 0 bytes.Keeping the replica open in the parent is not an option: the session-leader child then hangs forever in exit on macOS.
TIOCSDRAINWAITis overridden byptsclose.Change (tests only)
ghostel-test--env-commandon POSIX runsenv; printf GHOSTEL_HELD; read x; the native process helper waits for the marker, writes a newline to the PTY, then waits for exit as before. Windows path unchanged.ghostel-test--env-done-commandand the inline PWD-symlink script get the sameread xhold; their callers only wait for the marker and teardown kills the child.skip-unlessguards removed from the env tests.Verified: the held command survives a 1 s reader stall in the repro where plain
envreturns nothing;make -j8 allpasses.