Skip to content

Commit 30b45aa

Browse files
karthiknadigCopilot
andcommitted
fix: own subprocess probe descendants (Fixes #530)
Use Unix process groups and suspended Windows job assignment with process-local thread snapshots. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3ded49e commit 30b45aa

7 files changed

Lines changed: 695 additions & 35 deletions

File tree

‎.github/skills/rust-coding-skill/SKILL.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ Use contextual `expect` for poisoned locks in production code, matching the surr
6868
- Prefer raw string literals for regexes and backslash-heavy path examples to avoid malformed escapes.
6969
- Before documenting or logging a recommended config value, trace how the consumer uses it. For example, `environmentDirectories` contains directories that hold environments, not environment folders themselves.
7070

71+
## Subprocess Ownership
72+
73+
Keep Windows probe children suspended until job assignment succeeds, and fail closed if the primary thread cannot be identified. On stable Rust, a per-process `PssCaptureSnapshot(PSS_CAPTURE_THREADS)` can supply thread metadata without a system-wide Toolhelp scan or address-space clone; benchmark the launch boundary against the exact base on the same host rather than assuming enumeration is cheap. `CommandExt::creation_flags` replaces existing flags, so any runner-controlled flag contract must be explicit and tested. On Unix, signal the owned process group before reaping its leader (`waitid` with `WNOWAIT` preserves the PID until then), never after the numeric group ID could be reused.
74+
75+
For descendant-lifetime tests, use a readiness handshake and an OS-owned resource such as a file lock that is released on exit. Do not equate Unix PID disappearance with termination: grandchildren can be dead but still awaiting reaping by their parent or the OS reaper.
76+
7177
## Tests Must Prove the Change
7278

7379
Tests should demonstrate the behavior or performance invariant, not merely execute new lines.

‎crates/pet-python-utils/Cargo.toml‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ license.workspace = true
66

77
[target.'cfg(target_os = "windows")'.dependencies]
88
msvc_spectre_libs = { version = "0.1.1", features = ["error"] }
9-
windows-sys = { version = "0.59", features = ["Win32_Foundation", "Win32_System_Pipes"] }
9+
windows-sys = { version = "0.59", features = ["Win32_Foundation", "Win32_System_Pipes", "Win32_Security", "Win32_System_JobObjects", "Win32_System_Diagnostics_ProcessSnapshotting", "Win32_System_Diagnostics_Debug", "Win32_System_Kernel", "Win32_System_Threading"] }
1010

1111
[target.'cfg(unix)'.dependencies]
1212
libc = "0.2"
@@ -22,9 +22,6 @@ serde_json = "1.0.93"
2222
sha2 = "0.10.6"
2323
env_logger = "0.10.2"
2424

25-
[target.'cfg(windows)'.dev-dependencies]
26-
windows-sys = { version = "0.59", features = ["Win32_System_Threading"] }
27-
2825
[dev-dependencies]
2926
tempfile = "3.10"
3027

0 commit comments

Comments
 (0)