Skip to content

feat(supervisor): drain signal propagation and pidfd termination polling - #8

Merged
todie merged 1 commit into
developmentfrom
feat/drain-signaling-and-pidfd-polling
Oct 12, 2026
Merged

todie merged 1 commit into
developmentfrom
feat/drain-signaling-and-pidfd-polling

Conversation

@todie

@todie todie commented Oct 12, 2026

Copy link
Copy Markdown
Member

Summary

  • Drain Signal Forwarding: Upon transitioning to EnterDrain, TeardownCoordinator forwards the parsed catchable graceful signal (defaulting to SIGTERM) to all tracked process groups via kill_process_group and individual child processes.
  • PidFd Termination Polling: Added PidFd::wait_timeout(&self, timeout: Option<Duration>) -> io::Result<bool> using Linux poll(2) on the process descriptor (POLLIN / POLLHUP / POLLERR), providing race-free event-driven exit detection.
  • Child Supervision in kd init: Extended the container init subcommand to optionally accept and supervise an application process and its arguments under an isolated process group.
  • Exit Status Propagation: Fixed TeardownCoordinator::step to detect normal child completion and immediately force-terminate the state machine with the child's exit code, preventing hangs when a child exits cleanly without external signals.
  • Dependency Pin Alignment: Updated specs/0004 to match sha2 0.11.0 in Cargo.lock.

Verification Evidence

  • cargo test --workspace -j 2: All 55 tests pass cleanly.
  • make check: fmt-check, clippy (-D warnings), test, doc-test, and deny passed.
  • make hygiene: Passed (typos, sort-check, machete, spec-check, toolchain-check, pin-check).
  • make smoke: Passed with zero-I/O domain verification.
  • Verified 100% 7-bit ASCII purity on all modified files.
  • Manual verification: kd run -- echo hello exits 0, and kd init -- /bin/sh -c 'exit 42' exits 42.

Co-authored-by: Brokkr forge@forge.unsigned.gg
Reviewed-by: Mimir mimir@unsigned.gg

Forward graceful drain signal to tracked process groups and child processes.
Support event-driven process exit polling with PidFd::wait_timeout.
Support optional child command execution and supervision in kd init CLI.
Propagate exit code on normal termination in TeardownCoordinator::step.
Update specs/0004 sha2 pin to 0.11.0 to match Cargo.lock.

Co-authored-by: Brokkr <forge@forge.unsigned.gg>
Reviewed-by: Mimir <mimir@unsigned.gg>
@todie
todie merged commit 0a1f02d into development Oct 12, 2026
6 checks passed
@todie
todie deleted the feat/drain-signaling-and-pidfd-polling branch October 12, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant