Skip to content

Commit

Permalink
feat: Added wait method on FfmpegChild
Browse files Browse the repository at this point in the history
  • Loading branch information
emirror-de authored and nathanbabcock committed Apr 25, 2023
1 parent e7de411 commit 232301f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/child.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
io::{self, Write},
process::{Child, ChildStderr, ChildStdin, ChildStdout},
process::{Child, ChildStderr, ChildStdin, ChildStdout, ExitStatus},
};

use crate::error::{Error, Result};
Expand Down Expand Up @@ -97,6 +97,13 @@ impl FfmpegChild {
self.inner.kill()
}

/// Waits for the inner child process to finish execution.
///
/// Identical to `wait` in [`std::process::Child`].
pub fn wait(&mut self) -> io::Result<ExitStatus> {
self.inner.wait()
}

/// Wrap a [`std::process::Child`] in a `FfmpegChild`. Should typically only
/// be called by `FfmpegCommand::spawn`.
///
Expand Down
4 changes: 4 additions & 0 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,10 @@ impl FfmpegCommand {
/// Spawn the ffmpeg command as a child process, wrapping it in a
/// `FfmpegChild` interface.
///
/// Please note that if the result is not used with [wait()](FfmpegChild::wait)
/// the process is not cleaned up correctly resulting in a zombie process
/// until your main thread exits.
///
/// Identical to `spawn` in [`std::process::Command`].
pub fn spawn(&mut self) -> io::Result<FfmpegChild> {
self.inner.spawn().map(FfmpegChild::from_inner)
Expand Down

0 comments on commit 232301f

Please sign in to comment.