Commit 8c75fd1
test(daemon): wait for the zombie with waitid, not a sysinfo poll (#3231)
* test(daemon): wait for the zombie with waitid, not a sysinfo poll
`spawn_unreaped_wrapper` polled sysinfo for `ProcessStatus::Zombie` with a
5s deadline. That made the precondition depend on sysinfo *observing* the
zombie, which is a platform question rather than the one under test: the
poll timed out on the macOS nightly (#3150) while passing on Linux, failing
both tests before they reached an assertion.
`waitid(P_PID, pid, WEXITED | WNOWAIT)` answers the actual question — has it
exited — and `WNOWAIT` leaves the status pending so it stays a zombie for the
assertions and for `kill_group_and_reap`. Deterministic, no deadline.
The sysinfo check is kept as an explicit assertion rather than dropped,
because if the two ever disagree that is worth surfacing: `live_children`
treats an unseen pid as *not* recycled (`pid_recycled_into_stranger` returns
false for `None`), so on a platform where sysinfo cannot see zombies a pid
recycled into a stranger's zombie would be attributed to us and its group
killed — the #3067 case. The assertion names that consequence.
Not verified on macOS from here, so it is possible the platform gap is real
and this converts a timeout into a clear failure at the assertion. That is
the intended outcome either way: the failure then points at the mechanism.
Refs #3150
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* test(daemon): harden the zombie wait — EINTR, errno, and a bound
Three gaps in the `waitid` helper, all in the same direction: a failure
that has nothing to do with the child reported as the child failing.
`EINTR` is reachable — a signal handler installed without `SA_RESTART`
interrupts `waitid` (verified against a C repro; with `SA_RESTART` it is
restarted, as signal(7) documents). Nothing in the daemon's lib-test
binary installs such a handler today, but that is a property of the
current test set, not of the helper. Retry instead.
`errno` was discarded, so every failure printed the same line. `ECHILD`
(something reaped the wrapper out from under the test) and `EINVAL`
(wrong options for this platform) are exactly the answers a macOS
triage needs, and this helper exists because of a macOS triage.
Dropping the deadline outright traded a 5-second failure with a message
for an unbounded block: a wrapper that never exits would hang until the
CI job's own timeout killed the run and reported nothing. The wait now
runs on its own thread behind a 30-second `recv_timeout`, which bounds
the pathological case only — unlike the poll it replaces, it cannot
expire while the answer is already available.
Also narrows the sysinfo assertion's claim. sysinfo builds a process
entry from scratch here (`System::new()`), which on macOS gives up on a
zombie; a long-lived `DestroyWait` keeps its `System` across polls and
takes the update path instead, which can still see one. The assertion
fires on the create path, so its message should not condemn both.
Refs #3150
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent 7bfda31 commit 8c75fd1
1 file changed
Lines changed: 108 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
461 | 461 | | |
462 | 462 | | |
463 | 463 | | |
464 | | - | |
465 | | - | |
466 | 464 | | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
480 | 573 | | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | 574 | | |
487 | | - | |
488 | 575 | | |
489 | 576 | | |
490 | 577 | | |
| |||
0 commit comments