Wave icon indicating copy to clipboard operation
Wave copied to clipboard

Bound subprocess teardown when a detached child retains capture pipes

Open LunaStev opened this issue 3 weeks ago • 0 comments

Problem

A child that creates a separate POSIX session survives the process-group timeout cleanup. Retained stdout/stderr can also keep collector joins running beyond the configured deadline after the original parent exits.

Reproduction and evidence

Audited canonical master 69a67c6e0fb700f37ee6114f5a66d37ee13771a5 (0.0.1-alpha-dev). Matching checkout-built compiler/std were used for compiler probes on Linux amd64 with Rust 1.89.0 and LLVM 21.1.8. Artifact inspection, mocked/projection checks and foreign-target object emission are identified below and are not native execution on those operating systems.

Create a disposable child.py that spawns subprocess.Popen([sys.executable,"-c", CHILD], start_new_session=True) and sleeps 10 seconds. CHILD sleeps 3 seconds, writes a marker in the disposable directory and exits; it inherits capture pipes. Run:

target/debug/wave-tools exec --timeout 1 --capture -- python3 child.py

Observed: the child writes its marker after timeout, and the CLI returns after about 3 seconds rather than 1. A parent that exits successfully immediately after spawning the same bounded child also leaves the CLI waiting on pipe capture. All audit children self-terminated; no persistent workload was used.

Scope

Choose the supported descendant containment contract and make capture teardown independently bounded for success, timeout and cancellation.

Starting points: tools/src/process.rs:269, tools/src/process.rs:386.

Design discussion required

Recommended: bounded capture teardown plus stronger per-platform containment where available; define behavior when detached workloads cannot be contained. Process groups alone and arbitrary descendant ownership are different contracts. Do not silently weaken the installer child-process contract or promise portable termination of every possible detached process.

Please mention @LunaStev to discuss the design before starting implementation.

Completion criteria

  • [ ] A retained pipe cannot make teardown wait indefinitely past its deadline.
  • [ ] Test normal parent exit, timed-out parent, cancellation and a setsid descendant.
  • [ ] State platform containment limits accurately and retain process reaping/ownership safeguards.

Related: #507, #1016. Related broad trackers or completed implementations are context, not claims that their entire scope is unfinished.

LunaStev avatar Nov 12 '26 12:11 LunaStev