diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-22 17:42:04 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-22 17:42:47 -0500 |
| commit | a06baa56b95674fc626b3c3fd680d6a65357fe60 (patch) | |
| tree | cd9d867c2ca3cff5c1d6b3bd73377c44649fb075 /src/libstd/sys/vxworks/process | |
| parent | 8eb7c58dbb7b32701af113bc58722d0d1fefb1eb (diff) | |
Format the world
Diffstat (limited to 'src/libstd/sys/vxworks/process')
| -rw-r--r-- | src/libstd/sys/vxworks/process/process_vxworks.rs | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/src/libstd/sys/vxworks/process/process_vxworks.rs b/src/libstd/sys/vxworks/process/process_vxworks.rs index 79bfd770f8e..f926dfeb6d4 100644 --- a/src/libstd/sys/vxworks/process/process_vxworks.rs +++ b/src/libstd/sys/vxworks/process/process_vxworks.rs @@ -1,35 +1,39 @@ use crate::io::{self, Error, ErrorKind}; -use libc::{self, c_int, c_char}; -use libc::{RTP_ID}; use crate::sys; use crate::sys::cvt; use crate::sys::process::process_common::*; use crate::sys_common::thread; +use libc::RTP_ID; +use libc::{self, c_char, c_int}; //////////////////////////////////////////////////////////////////////////////// // Command //////////////////////////////////////////////////////////////////////////////// impl Command { - pub fn spawn(&mut self, default: Stdio, needs_stdin: bool) - -> io::Result<(Process, StdioPipes)> { - use crate::sys::{cvt_r}; + pub fn spawn( + &mut self, + default: Stdio, + needs_stdin: bool, + ) -> io::Result<(Process, StdioPipes)> { + use crate::sys::cvt_r; const CLOEXEC_MSG_FOOTER: &'static [u8] = b"NOEX"; let envp = self.capture_env(); if self.saw_nul() { - return Err(io::Error::new(ErrorKind::InvalidInput, - "nul byte found in provided data")); + return Err(io::Error::new(ErrorKind::InvalidInput, "nul byte found in provided data")); } let (ours, theirs) = self.setup_io(default, needs_stdin)?; let mut p = Process { pid: 0, status: None }; unsafe { macro_rules! t { - ($e:expr) => (match $e { - Ok(e) => e, - Err(e) => return Err(e.into()), - }) + ($e:expr) => { + match $e { + Ok(e) => e, + Err(e) => return Err(e.into()), + } + }; } let mut orig_stdin = libc::STDIN_FILENO; @@ -53,7 +57,9 @@ impl Command { t!(cvt(libc::chdir(cwd.as_ptr()))); } - let c_envp = envp.as_ref().map(|c| c.as_ptr()) + let c_envp = envp + .as_ref() + .map(|c| c.as_ptr()) .unwrap_or_else(|| *sys::os::environ() as *const _); let stack_size = thread::min_stack(); @@ -61,13 +67,13 @@ impl Command { let _lock = sys::os::env_lock(); let ret = libc::rtpSpawn( - self.get_argv()[0], // executing program + self.get_argv()[0], // executing program self.get_argv().as_ptr() as *mut *const c_char, // argv c_envp as *mut *const c_char, - 100 as c_int, // initial priority - stack_size, // initial stack size. - 0, // options - 0 // task options + 100 as c_int, // initial priority + stack_size, // initial stack size. + 0, // options + 0, // task options ); // Because FileDesc was not used, each duplicated file descriptor @@ -127,8 +133,10 @@ impl Process { // and used for another process, and we probably shouldn't be killing // random processes, so just return an error. if self.status.is_some() { - Err(Error::new(ErrorKind::InvalidInput, - "invalid argument: can't kill an exited process")) + Err(Error::new( + ErrorKind::InvalidInput, + "invalid argument: can't kill an exited process", + )) } else { cvt(unsafe { libc::kill(self.pid, libc::SIGKILL) }).map(|_| ()) } @@ -137,7 +145,7 @@ impl Process { pub fn wait(&mut self) -> io::Result<ExitStatus> { use crate::sys::cvt_r; if let Some(status) = self.status { - return Ok(status) + return Ok(status); } let mut status = 0 as c_int; cvt_r(|| unsafe { libc::waitpid(self.pid, &mut status, 0) })?; @@ -147,12 +155,10 @@ impl Process { pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> { if let Some(status) = self.status { - return Ok(Some(status)) + return Ok(Some(status)); } let mut status = 0 as c_int; - let pid = cvt(unsafe { - libc::waitpid(self.pid, &mut status, libc::WNOHANG) - })?; + let pid = cvt(unsafe { libc::waitpid(self.pid, &mut status, libc::WNOHANG) })?; if pid == 0 { Ok(None) } else { |
