diff options
| author | David Tolnay <dtolnay@gmail.com> | 2019-11-27 10:28:39 -0800 |
|---|---|---|
| committer | David Tolnay <dtolnay@gmail.com> | 2019-11-29 18:37:58 -0800 |
| commit | c34fbfaad38cf5829ef5cfe780dc9d58480adeaa (patch) | |
| tree | e57b66ed06aec18dc13ff7f14a243ca3dc3c27d1 /src/libstd/sys/unix/process/process_fuchsia.rs | |
| parent | 9081929d45f12d3f56d43b1d6db7519981580fc9 (diff) | |
| download | rust-c34fbfaad38cf5829ef5cfe780dc9d58480adeaa.tar.gz rust-c34fbfaad38cf5829ef5cfe780dc9d58480adeaa.zip | |
Format libstd/sys with rustfmt
This commit applies rustfmt with rust-lang/rust's default settings to
files in src/libstd/sys *that are not involved in any currently open PR*
to minimize merge conflicts. THe list of files involved in open PRs was
determined by querying GitHub's GraphQL API with this script:
https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8
With the list of files from the script in outstanding_files, the
relevant commands were:
$ find src/libstd/sys -name '*.rs' \
| xargs rustfmt --edition=2018 --unstable-features --skip-children
$ rg libstd/sys outstanding_files | xargs git checkout --
Repeating this process several months apart should get us coverage of
most of the rest of the files.
To confirm no funny business:
$ git checkout $THIS_COMMIT^
$ git show --pretty= --name-only $THIS_COMMIT \
| xargs rustfmt --edition=2018 --unstable-features --skip-children
$ git diff $THIS_COMMIT # there should be no difference
Diffstat (limited to 'src/libstd/sys/unix/process/process_fuchsia.rs')
| -rw-r--r-- | src/libstd/sys/unix/process/process_fuchsia.rs | 102 |
1 files changed, 67 insertions, 35 deletions
diff --git a/src/libstd/sys/unix/process/process_fuchsia.rs b/src/libstd/sys/unix/process/process_fuchsia.rs index 486c12f9bf8..f0bd1cdfed5 100644 --- a/src/libstd/sys/unix/process/process_fuchsia.rs +++ b/src/libstd/sys/unix/process/process_fuchsia.rs @@ -1,11 +1,11 @@ use crate::convert::TryInto; -use crate::io; use crate::fmt; +use crate::io; use crate::mem; use crate::ptr; -use crate::sys::process::zircon::{Handle, zx_handle_t}; use crate::sys::process::process_common::*; +use crate::sys::process::zircon::{zx_handle_t, Handle}; use libc::{c_int, size_t}; @@ -14,13 +14,18 @@ use libc::{c_int, size_t}; //////////////////////////////////////////////////////////////////////////////// impl Command { - pub fn spawn(&mut self, default: Stdio, needs_stdin: bool) - -> io::Result<(Process, StdioPipes)> { + pub fn spawn( + &mut self, + default: Stdio, + needs_stdin: bool, + ) -> io::Result<(Process, StdioPipes)> { let envp = self.capture_env(); if self.saw_nul() { - return Err(io::Error::new(io::ErrorKind::InvalidInput, - "nul byte found in provided data")); + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + "nul byte found in provided data", + )); } let (ours, theirs) = self.setup_io(default, needs_stdin)?; @@ -32,21 +37,23 @@ impl Command { pub fn exec(&mut self, default: Stdio) -> io::Error { if self.saw_nul() { - return io::Error::new(io::ErrorKind::InvalidInput, - "nul byte found in provided data") + return io::Error::new(io::ErrorKind::InvalidInput, "nul byte found in provided data"); } match self.setup_io(default, true) { Ok((_, _)) => { // FIXME: This is tough because we don't support the exec syscalls unimplemented!(); - }, + } Err(e) => e, } } - unsafe fn do_exec(&mut self, stdio: ChildPipes, maybe_envp: Option<&CStringArray>) - -> io::Result<zx_handle_t> { + unsafe fn do_exec( + &mut self, + stdio: ChildPipes, + maybe_envp: Option<&CStringArray>, + ) -> io::Result<zx_handle_t> { use crate::sys::process::zircon::*; let envp = match maybe_envp { @@ -108,10 +115,15 @@ impl Command { let mut process_handle: zx_handle_t = 0; zx_cvt(fdio_spawn_etc( ZX_HANDLE_INVALID, - FDIO_SPAWN_CLONE_JOB | FDIO_SPAWN_CLONE_LDSVC | FDIO_SPAWN_CLONE_NAMESPACE - | FDIO_SPAWN_CLONE_ENVIRON, // this is ignored when envp is non-null - self.get_program().as_ptr(), self.get_argv().as_ptr(), envp, - actions.len() as size_t, actions.as_ptr(), + FDIO_SPAWN_CLONE_JOB + | FDIO_SPAWN_CLONE_LDSVC + | FDIO_SPAWN_CLONE_NAMESPACE + | FDIO_SPAWN_CLONE_ENVIRON, // this is ignored when envp is non-null + self.get_program().as_ptr(), + self.get_argv().as_ptr(), + envp, + actions.len() as size_t, + actions.as_ptr(), &mut process_handle, ptr::null_mut(), ))?; @@ -137,7 +149,9 @@ impl Process { pub fn kill(&mut self) -> io::Result<()> { use crate::sys::process::zircon::*; - unsafe { zx_cvt(zx_task_kill(self.handle.raw()))?; } + unsafe { + zx_cvt(zx_task_kill(self.handle.raw()))?; + } Ok(()) } @@ -151,16 +165,26 @@ impl Process { let mut avail: size_t = 0; unsafe { - zx_cvt(zx_object_wait_one(self.handle.raw(), ZX_TASK_TERMINATED, - ZX_TIME_INFINITE, ptr::null_mut()))?; - zx_cvt(zx_object_get_info(self.handle.raw(), ZX_INFO_PROCESS, - &mut proc_info as *mut _ as *mut libc::c_void, - mem::size_of::<zx_info_process_t>(), &mut actual, - &mut avail))?; + zx_cvt(zx_object_wait_one( + self.handle.raw(), + ZX_TASK_TERMINATED, + ZX_TIME_INFINITE, + ptr::null_mut(), + ))?; + zx_cvt(zx_object_get_info( + self.handle.raw(), + ZX_INFO_PROCESS, + &mut proc_info as *mut _ as *mut libc::c_void, + mem::size_of::<zx_info_process_t>(), + &mut actual, + &mut avail, + ))?; } if actual != 1 { - return Err(io::Error::new(io::ErrorKind::InvalidData, - "Failed to get exit status of process")); + return Err(io::Error::new( + io::ErrorKind::InvalidData, + "Failed to get exit status of process", + )); } Ok(ExitStatus(proc_info.return_code)) } @@ -174,23 +198,31 @@ impl Process { let mut avail: size_t = 0; unsafe { - let status = zx_object_wait_one(self.handle.raw(), ZX_TASK_TERMINATED, - 0, ptr::null_mut()); + let status = + zx_object_wait_one(self.handle.raw(), ZX_TASK_TERMINATED, 0, ptr::null_mut()); match status { - 0 => { }, // Success + 0 => {} // Success x if x == ERR_TIMED_OUT => { return Ok(None); - }, - _ => { panic!("Failed to wait on process handle: {}", status); }, + } + _ => { + panic!("Failed to wait on process handle: {}", status); + } } - zx_cvt(zx_object_get_info(self.handle.raw(), ZX_INFO_PROCESS, - &mut proc_info as *mut _ as *mut libc::c_void, - mem::size_of::<zx_info_process_t>(), &mut actual, - &mut avail))?; + zx_cvt(zx_object_get_info( + self.handle.raw(), + ZX_INFO_PROCESS, + &mut proc_info as *mut _ as *mut libc::c_void, + mem::size_of::<zx_info_process_t>(), + &mut actual, + &mut avail, + ))?; } if actual != 1 { - return Err(io::Error::new(io::ErrorKind::InvalidData, - "Failed to get exit status of process")); + return Err(io::Error::new( + io::ErrorKind::InvalidData, + "Failed to get exit status of process", + )); } Ok(Some(ExitStatus(proc_info.return_code))) } |
