process: Fix clippy warnings

This commit is contained in:
Ivan Petkov
2019-06-24 16:57:19 -07:00
parent caf43221b5
commit f16725ea9f
7 changed files with 60 additions and 46 deletions
+18 -14
View File
@@ -38,6 +38,7 @@ use std::fmt;
use std::io;
use std::os::unix::io::{AsRawFd, RawFd};
use std::process::{self, ExitStatus};
use super::SpawnedChild;
use tokio_io::IoFuture;
use tokio_reactor::{Handle, PollEvented};
@@ -66,21 +67,24 @@ impl fmt::Debug for Child {
}
}
pub(crate) fn spawn_child(cmd: &mut process::Command, handle: &Handle) -> io::Result<SpawnedChild> {
let mut child = cmd.spawn()?;
let stdin = stdio(child.stdin.take(), handle)?;
let stdout = stdio(child.stdout.take(), handle)?;
let stderr = stdio(child.stderr.take(), handle)?;
let signal = Signal::with_handle(libc::SIGCHLD, handle).flatten_stream();
Ok(SpawnedChild {
child: Child {
inner: Reaper::new(child, signal),
},
stdin,
stdout,
stderr,
})
}
impl Child {
pub fn new(mut inner: process::Child, handle: &Handle)
-> io::Result<(Child, Option<ChildStdin>, Option<ChildStdout>, Option<ChildStderr>)>
{
let stdin = stdio(inner.stdin.take(), handle)?;
let stdout = stdio(inner.stdout.take(), handle)?;
let stderr = stdio(inner.stderr.take(), handle)?;
let signal = Signal::with_handle(libc::SIGCHLD, handle).flatten_stream();
let child = Child {
inner: Reaper::new(inner, signal),
};
Ok((child, stdin, stdout, stderr))
}
pub fn id(&self) -> u32 {
self.inner.id()
+2 -2
View File
@@ -124,7 +124,7 @@ mod test {
impl Wait for MockWait {
fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> {
let ret = if self.num_wait_until_status == self.total_waits {
Some(self.status.clone())
Some(self.status)
} else {
None
};
@@ -171,7 +171,7 @@ mod test {
#[test]
fn reaper() {
let exit = ExitStatus::from_raw(0);
let mock = MockWait::new(exit.clone(), 3);
let mock = MockWait::new(exit, 3);
let mut grim = Reaper::new(mock, MockStream::new(vec!(
None,
Some(()),