Repository navigation
Answer a run once its tree has ended and read a stopped child as running - #739
Merged
Merged
Conversation
run_to_end and capture_until waited for both output pipes to reach their end after the leader exited. On macOS the standard library makes a pipe and marks each end close-on-exec in two calls, so a long-lived child another thread starts in between keeps both ends, and the run then reported TimedOut although its leader had answered. A helper that left the group held the answer the same way. Once the leader exits, the tree is ended, the run waits until no member of the leader's group is alive (the job's active process count on Windows), then reads both pipes until they are empty and answers. Signal 0 to the group cannot say that on macOS, which refuses it with EPERM while a killed member is still exiting. The escaped-holder contract now expects the leader's whole answer, output near a pipe buffer included, and the held-pipe capture answers at the exit; a live leader still bounds the capture deadline.
has_exited asked waitid for WEXITED with WNOWAIT, and macOS answers that call for a stopped child too. A run then took the stop for an exit, found nothing waitpid could reap and failed with "observed exit could not be reaped" at once, which ssh host resolution reports as SshFailed. Only an exit, a kill or a core dump now counts, so a stopped child runs to the deadline and is ended there.
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.
Closes #729
Related: #728
Summary
hide-kitretirement_without_a_herdr_server_finishes_when_no_plugin_is_registered가 은퇴를Failed로 받았다.pipe()로 만든 뒤 두 끝에FD_CLOEXEC를 따로 건다.posix_spawn한 자식은 두 끝을 물려받는다. Linux는pipe2(O_CLOEXEC)라 이 틈이 없다.perl ... sleep 60, test binary re-exec)이 launchctl 대역 run의 write end를 쥐었다.exit 113했지만run_to_end가 EOF를 5 s deadline까지 기다려TimedOut이 됐다. 부하는 그 틈에서 스레드가 선점될 확률을 키울 뿐이다.claude -p등)을 띄운다.codex daemon명령, 로그인 셸 PATH 읽기의run_to_end가 멀쩡한 답을 두고TimedOut을 낼 수 있었다.hide-platform/src/process.rs): 리더 exit를 보면 트리를 끝내고, 트리에 살아 있는 것이 없음을 확인한 뒤 두 pipe를 빈 상태(EAGAIN)까지 읽고 답한다.capture_until도 같은 규칙으로 맞췄다.is_alive로 본다. Windows는 job의 active process 수다.EPERM을 답한다(이 PR을 만들다 실측).waitid(WEXITED|WNOHANG|WNOWAIT)는 멈춘(SIGSTOP) child에도 답한다.SshFailed로 보고했다.Review
an_escaped_pipe_holder_cannot_extend_the_run_deadline의 기대를TimedOut에서 리더의 답(code 0, 출력 전부)으로 바꿨다.TimedOut은 사실과 다른 답이었다.a_pipe_holder_outside_the_tree_does_not_hold_the_answer다. 같은 test에 "exit 직전에 pipe 버퍼(macOS 16 KiB) 가까이 쓴 출력이 잘리지 않는다"를 더했다.capture_until의held_pipe계약도 바뀌었다(group 안 helper가 pipe를 쥐면 deadline 대신 exit에서 helper를 끝내고 답한다). deadline 상한은 살아 있는 리더로 따로 남겼다.hide-platform/src/process.rs- 모든run_to_end호출의 failure path. 트리 종료 확인 전에는 답하지 않고, 확인 뒤에는 한 번이 아니라 빈 상태까지 읽는다./proc한 번 훑기이고, kill된 구성원이 끝날 때까지 20 ms마다 반복한다.posix_spawnCLOEXEC_DEFAULT는 이번 범위 밖).docs/ARCHITECTURE.md- 세 OS가 같은 코드인 이유와, Windows에서 이 누수가 std 경로로 생기지 않는 이유(std의CREATE_PROCESS_LOCK, job에 breakaway 없음).Evidence
sleep 3을 계속 spawn하는 동안run_to_end(sh -c 'exit 113') 600회.lsof로 그sleep이 run의 pipe 양끝을 쥔 것을 확인했다.lsof로 확인). std 1.90anon_pipe소스에서 macOS는pipe다음set_cloexec, Linux는pipe2다.process.rs+ 새 계약 test): outside-holder test는 "the run waited for a write end outside its tree"(5.07 s)로, held-pipe capture는 30 s deadline으로 실패했다.a_stopped_child_is_not_a_finished_one은 수정 전 0.05 s 만에Err(Wait("observed exit could not be reaped"))였다.hide-platformprocess 계약은 stopped-child 수정 전 36개를 15회 반복해 0 실패, 최종 37개 통과.hide-kitlib 145개 3회,hide-agent-hooks전부 통과. fmt, clippy(-D warnings) 통과./procgroup 나열, job active process 수)는 로컬에서 컴파일·실행하지 못했고 CI lane(rust workspace, windows check, os contract)에 맡긴다./bin/sh대역)가 5 s 뒤에도 살아 있고(stateS) exit가 한 번도 보이지 않았다. pipe 누수가 아니라 그 storm에서 프로세스 시작 자체가 5 s를 넘긴 것이다.TimedOut을 답하는 경우라 이 PR은 다루지 않는다.