assert_cmd icon indicating copy to clipboard operation
assert_cmd copied to clipboard

Should `with_stdin` stream content in?

Open epage opened this issue 7 years ago • 1 comments

For #24 we added support for passing a file's contents to stdin (see #26).

Should we make it stream contents in?

  • From a file, read and pass in a chunk at a time
  • Support a Read object being passed in

epage avatar Jul 19 '18 03:07 epage

Aside from the API nicety of allowing a Read object (which could be nice), the only thing this buys you is lower memory usage by not storing the entire file contents. You have to finish writing stdin before you call wait or wait_with_output because those close stdin before waiting to avoid deadlock. You actually might want to consider refactoring the current code to write stdin on a separate thread and then read stdout/stderr in parallel to avoid possible deadlock. Right now if the spawned process produces enough output to fill up its stdout or stderr buffers it'll block trying to write those, and if you are still writing stdin data you'll be blocked as well. I've got a wait_with_input_output function that does this in sccache which you can copy if you'd like. (Linking to an older version because the current source uses tokio-io and futures.)

luser avatar Jul 27 '18 15:07 luser