-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libstd fuchsia fixes #64023
libstd fuchsia fixes #64023
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
use crate::os::unix::prelude::*; | ||
|
||
use crate::ffi::{OsString, OsStr, CString, CStr}; | ||
use crate::ffi::{OsString, OsStr, CString}; | ||
use crate::fmt; | ||
use crate::io; | ||
use crate::ptr; | ||
use crate::sys::fd::FileDesc; | ||
use crate::sys::fs::{File, OpenOptions}; | ||
use crate::sys::fs::File; | ||
use crate::sys::pipe::{self, AnonPipe}; | ||
use crate::sys_common::process::{CommandEnv, DefaultEnvKey}; | ||
use crate::collections::BTreeMap; | ||
|
||
#[cfg(not(target_os = "fuchsia"))] | ||
use { | ||
crate::ffi::CStr, | ||
crate::sys::fs::OpenOptions, | ||
}; | ||
|
||
use libc::{c_int, gid_t, uid_t, c_char, EXIT_SUCCESS, EXIT_FAILURE}; | ||
|
||
cfg_if::cfg_if! { | ||
if #[cfg(target_os = "redox")] { | ||
if #[cfg(target_os = "fuchsia")] { | ||
// fuchsia doesn't have /dev/null | ||
} else if #[cfg(target_os = "redox")] { | ||
const DEV_NULL: &'static str = "null:\0"; | ||
} else { | ||
const DEV_NULL: &'static str = "/dev/null\0"; | ||
|
@@ -83,6 +91,11 @@ pub enum ChildStdio { | |
Inherit, | ||
Explicit(c_int), | ||
Owned(FileDesc), | ||
|
||
// On Fuchsia, null stdio is the default, so we simply don't specify | ||
// any actions at the time of spawning. | ||
#[cfg(target_os = "fuchsia")] | ||
Null, | ||
} | ||
|
||
pub enum Stdio { | ||
|
@@ -301,6 +314,7 @@ impl Stdio { | |
Ok((ChildStdio::Owned(theirs.into_fd()), Some(ours))) | ||
} | ||
|
||
#[cfg(not(target_os = "fuchsia"))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not in love with these inline cfgs, but they seem to match the way There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. |
||
Stdio::Null => { | ||
let mut opts = OpenOptions::new(); | ||
opts.read(readable); | ||
|
@@ -311,6 +325,11 @@ impl Stdio { | |
let fd = File::open_c(&path, &opts)?; | ||
Ok((ChildStdio::Owned(fd.into_fd()), None)) | ||
} | ||
|
||
#[cfg(target_os = "fuchsia")] | ||
Stdio::Null => { | ||
Ok((ChildStdio::Null, None)) | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -333,6 +352,9 @@ impl ChildStdio { | |
ChildStdio::Inherit => None, | ||
ChildStdio::Explicit(fd) => Some(fd), | ||
ChildStdio::Owned(ref fd) => Some(fd.raw()), | ||
|
||
#[cfg(target_os = "fuchsia")] | ||
ChildStdio::Null => None, | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this file is shared amongst most platforms, would it be possible to avoid the fuchsia-specific cfgs? Could
Null
be used on all platforms and only at the very end it's lowered to/dev/null
?