rust-lang / rust-lang/rfcs

memory bound for process::Child::wait_with_output

Open
#1,613 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

T-libs
Dominant language
Markdown
Stars
6.6k
Forks
1.7k
Avg merge
16h 14m
Merged PRs (30d)
1

Description

Hi Folks: I just ran into an issue where I

let test = Command::new("yes").stdout(Stdio::piped()).spawn().unwrap();
let _res = test.wait_with_output();

and that immediately allocated 16 gigs of memory and OOM'd my machine.

Would it be possible to add a (required or optional) memory bound to wait_with_output or a new function like that?

This will also allow easy interoperability with SECCOMP jailed subprocesses.

The proposal could look something like this

Wait With Bounded Output

fn wait_with_bounded_output(self, max_stdout_bytes : usize, max_stderr_bytes : usize) -> Result

Simultaneously waits for the child to exit and collect all remaining output on the stdout/stderr handles, returning an Output instance until the max_stderr or max_stdout bounds have been reached.

If either bound has been reached, the function returns success = false, code = None in the ExitStatus and one of the two Vec will be filled to either max_stdout_bytes or max_stderr_bytes respectively
This function may be invoked again until both vectors have excess capacity.

Does this sound acceptable to the community? If so, I can draft an RFC pull request.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing process::Child::wait_with_output and the proposed bounded-output behavior described in the issue. Determine the API and RFC changes needed for bounded stdout and stderr collection, including repeated invocation and exit-status behavior. Done means an accepted design or RFC pull request that addresses the stated memory and output-bound requirements.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.