oconnor663 / duct.rs

a Rust library for running child processes
MIT License
795 stars 34 forks source link

How to ignore non-zero exit status? #94

Closed Boscop closed 1 year ago

Boscop commented 3 years ago
  1. ffmpeg -list_devices true -f dshow -i dummy always returns 1, even though it prints the desired output: https://trac.ffmpeg.org/wiki/DirectShow

I'm calling duct like this:

let output = cmd!("ffmpeg", "-list_devices", "true", "-f", "dshow", "-i", "dummy")
    .stdout_stderr_swap() // temp workaround (see below)
    .read()?;

duct fails with:

Error:
    command ["ffmpeg", "-list_devices", "true", "-f", "dshow", "-i", "dummy"] exited with code 1

Thus not returning the output that I want to parse.

How can I get the output, regardless of exit status?


  1. Btw, ffmpeg prints the output in stderr always, to keep stdout for piping video out. (It prints errors to ffmpeg.log). What's the closest to a .read() equivalent for stderr? :)
Boscop commented 3 years ago

Ah, just found the unchecked method -.-

oconnor663 commented 3 years ago

Yep, unchecked. If you're interested in stderr output, it's easier to stop using the read helper method and go back to the more general run function, with something like .stdout_capture().stderr_capture().run(). Let me know if you have any feedback on this part of the API.

azzamsa commented 1 year ago

@Boscop I think it is safe to close this issue for now.