Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5da1123
Update zx_time_t to an i64
tmandry Aug 30, 2019
403701f
Don't try to use /dev/null on Fuchsia
tmandry Aug 30, 2019
7bfa2be
fuchsia: Don't fail to spawn if no stdin exists
tmandry Aug 31, 2019
5f91ad0
fuchsia: Fix default environment behavior when spawning
tmandry Aug 31, 2019
c86ea34
Ensure all warnings are emitted even on warnings=warn
Mark-Simulacrum Sep 2, 2019
fda251b
Rename --warnings=allow to --warnings=warn
Mark-Simulacrum Sep 2, 2019
74563b4
Restrict error code length to 80 columns
Mark-Simulacrum Sep 4, 2019
b437240
Replace diagnostic plugins with macro_rules
Mark-Simulacrum Sep 4, 2019
3f1dc32
Remove codegen dependencies
Mark-Simulacrum Sep 4, 2019
4de4f30
Fix error index generator for new register_diagnostics API
Mark-Simulacrum Sep 4, 2019
41b39fc
Remove rustc_diagnostic_macros feature
Mark-Simulacrum Sep 4, 2019
5153db1
Explicitly create test tempdir
Mark-Simulacrum Sep 5, 2019
8ddbe76
Upgrade env_logger to 0.6
mati865 Aug 29, 2019
c1d29ee
Aggregation of cosmetic changes made during work on REPL PRs: librustc
alexreg Sep 6, 2019
fd48ca2
Apply suggestions from code review
alexreg Sep 6, 2019
49d2fd1
Aggregation of cosmetic changes made during work on REPL PRs: libsyntax
alexreg Sep 6, 2019
553a56d
Apply suggestions from code review
alexreg Sep 6, 2019
2bcabf6
compiletest: Match suffixed environments
smaeul Sep 3, 2019
8bee18b
Rollup merge of #64023 - tmandry:libstd-fuchsia-fixes, r=cramertj
Centril Sep 7, 2019
3c4a586
Rollup merge of #64098 - Mark-Simulacrum:always-warn, r=alexcrichton
Centril Sep 7, 2019
89a69fd
Rollup merge of #64139 - Mark-Simulacrum:strip-legacy-proc-macro, r=p…
Centril Sep 7, 2019
c530672
Rollup merge of #64226 - alexreg:rush-pr-3, r=centril
Centril Sep 7, 2019
c70b768
Rollup merge of #64227 - alexreg:rush-pr-4, r=centril
Centril Sep 7, 2019
448b38f
Rollup merge of #64235 - mati865:env_logger, r=alexcrichton
Centril Sep 7, 2019
635c3bc
Rollup merge of #64258 - smaeul:patch/arm-tests, r=Mark-Simulacrum
Centril Sep 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fuchsia: Don't fail to spawn if no stdin exists
  • Loading branch information
tmandry committed Aug 31, 2019
commit 7bfa2be4efa2d4649e8db7548f1980156d58017e
57 changes: 36 additions & 21 deletions src/libstd/sys/unix/process/process_fuchsia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,45 @@ impl Command {
None => ptr::null(),
};

let make_action = |local_io: &ChildStdio, target_fd| if let Some(local_fd) = local_io.fd() {
fdio_spawn_action_t {
action: FDIO_SPAWN_ACTION_TRANSFER_FD,
local_fd,
target_fd,
..Default::default()
}
} else {
if let ChildStdio::Null = local_io {
// acts as no-op
return Default::default();
}
fdio_spawn_action_t {
action: FDIO_SPAWN_ACTION_CLONE_FD,
local_fd: target_fd,
target_fd,
..Default::default()
let make_action = |local_io: &ChildStdio, target_fd| -> io::Result<fdio_spawn_action_t> {
if let Some(local_fd) = local_io.fd() {
Ok(fdio_spawn_action_t {
action: FDIO_SPAWN_ACTION_TRANSFER_FD,
local_fd,
target_fd,
..Default::default()
})
} else {
if let ChildStdio::Null = local_io {
// acts as no-op
return Ok(Default::default());
}

let mut handle = ZX_HANDLE_INVALID;
let status = fdio_fd_clone(target_fd, &mut handle);
if status == ERR_INVALID_ARGS || status == ERR_NOT_SUPPORTED {
// This descriptor is closed; skip it rather than generating an
// error.
return Ok(Default::default());
}
zx_cvt(status)?;

let mut cloned_fd = 0;
zx_cvt(fdio_fd_create(handle, &mut cloned_fd))?;

Ok(fdio_spawn_action_t {
action: FDIO_SPAWN_ACTION_TRANSFER_FD,
local_fd: cloned_fd as i32,
target_fd,
..Default::default()
})
}
};

// Clone stdin, stdout, and stderr
let action1 = make_action(&stdio.stdin, 0);
let action2 = make_action(&stdio.stdout, 1);
let action3 = make_action(&stdio.stderr, 2);
let action1 = make_action(&stdio.stdin, 0)?;
let action2 = make_action(&stdio.stdout, 1)?;
let action3 = make_action(&stdio.stderr, 2)?;
let actions = [action1, action2, action3];

// We don't want FileDesc::drop to be called on any stdio. fdio_spawn_etc
Expand All @@ -88,7 +103,7 @@ impl Command {

let mut process_handle: zx_handle_t = 0;
zx_cvt(fdio_spawn_etc(
0,
ZX_HANDLE_INVALID,
FDIO_SPAWN_CLONE_JOB | FDIO_SPAWN_CLONE_LDSVC | FDIO_SPAWN_CLONE_NAMESPACE,
self.get_argv()[0], self.get_argv().as_ptr(), envp,
actions.len() as size_t, actions.as_ptr(),
Expand Down
6 changes: 5 additions & 1 deletion src/libstd/sys/unix/process/zircon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

use crate::convert::TryInto;
use crate::io;
use crate::os::raw::c_char;
use crate::i64;
use crate::mem::MaybeUninit;
use crate::os::raw::c_char;

use libc::{c_int, c_void, size_t};

Expand Down Expand Up @@ -122,6 +123,9 @@ extern {
argv: *const *const c_char, envp: *const *const c_char,
action_count: size_t, actions: *const fdio_spawn_action_t,
process: *mut zx_handle_t, err_msg: *mut c_char) -> zx_status_t;

pub fn fdio_fd_clone(fd: c_int, out_handle: *mut zx_handle_t) -> zx_status_t;
pub fn fdio_fd_create(handle: zx_handle_t, fd: *mut c_int) -> zx_status_t;
}

// fdio_spawn_etc flags
Expand Down