Skip to content

The capture drain treats an interrupted read as end-of-pipe #355

Description

@blooop

Question

ProcessRunner's drain loop treats a read error as end-of-pipe. At rust/devlaunch-runner/src/lib.rs:816-826 (as of PR #343), Ok(0) | Err(_) => break collapses every error into EOF, where the read_to_end it replaced retried on ErrorKind::Interrupted.

The review of PR #343 proved it with a reader yielding "ab", one Interrupted, then "cd": the old code returns "abcd", the new code returns "ab". The result is silent truncation reported as a successful Ran — precisely the harm that PR's design notes cite as the reason not to have a bounded join return String::new().

Unreachable today, and it is worth writing down why, because that is what makes this low priority rather than urgent: every signal handler in the workspace is installed through libc::signal, which on glibc carries BSD semantics with SA_RESTART, so a slow read is restarted by the kernel rather than failing with EINTR. Anything that installs a handler with sigaction and omits SA_RESTART makes this live — so the fix is cheap insurance against a change nobody would connect to this file.

The fix is one match arm: retry on ErrorKind::Interrupted, break on other errors. Red first, with the injected-reader shape the reviewer used — a test that only exercises real pipes cannot reach this.

While there, two nits from the same review:

  • capture pays DRAIN_GRACE twice serially (measured 1.01 s with both pipes held) where the doc comment reads as a single bound. Either make it one shared deadline across both pipes or correct the doc.
  • session's reader is an abandon rather than a bound, which is correct as written — no change wanted, listed so it is not mistaken for an oversight.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions