mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
std: Rename Stdio::None to Stdio::Null
This better reflects what it's actually doing as we don't actually have an option for "leave this I/O slot as an empty hole".
This commit is contained in:
parent
627515a7ff
commit
b8bd8f3d7c
@ -385,7 +385,7 @@ fn setup_io(io: &Stdio, readable: bool)
|
|||||||
}
|
}
|
||||||
StdioImp::Raw(ref owned) => (imp::Stdio::Raw(owned.raw()), None, None),
|
StdioImp::Raw(ref owned) => (imp::Stdio::Raw(owned.raw()), None, None),
|
||||||
StdioImp::Inherit => (imp::Stdio::Inherit, None, None),
|
StdioImp::Inherit => (imp::Stdio::Inherit, None, None),
|
||||||
StdioImp::None => (imp::Stdio::None, None, None),
|
StdioImp::Null => (imp::Stdio::Null, None, None),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,7 +439,7 @@ enum StdioImp {
|
|||||||
MakePipe,
|
MakePipe,
|
||||||
Raw(imp::RawStdio),
|
Raw(imp::RawStdio),
|
||||||
Inherit,
|
Inherit,
|
||||||
None,
|
Null,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Stdio {
|
impl Stdio {
|
||||||
@ -454,7 +454,7 @@ impl Stdio {
|
|||||||
/// This stream will be ignored. This is the equivalent of attaching the
|
/// This stream will be ignored. This is the equivalent of attaching the
|
||||||
/// stream to `/dev/null`
|
/// stream to `/dev/null`
|
||||||
#[stable(feature = "process", since = "1.0.0")]
|
#[stable(feature = "process", since = "1.0.0")]
|
||||||
pub fn null() -> Stdio { Stdio(StdioImp::None) }
|
pub fn null() -> Stdio { Stdio(StdioImp::Null) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromInner<imp::RawStdio> for Stdio {
|
impl FromInner<imp::RawStdio> for Stdio {
|
||||||
|
@ -275,7 +275,7 @@ pub struct Process {
|
|||||||
|
|
||||||
pub enum Stdio {
|
pub enum Stdio {
|
||||||
Inherit,
|
Inherit,
|
||||||
None,
|
Null,
|
||||||
Raw(c_int),
|
Raw(c_int),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,7 +416,7 @@ impl Process {
|
|||||||
Stdio::Raw(fd.into_raw())
|
Stdio::Raw(fd.into_raw())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
s @ Stdio::None |
|
s @ Stdio::Null |
|
||||||
s @ Stdio::Inherit |
|
s @ Stdio::Inherit |
|
||||||
s @ Stdio::Raw(_) => Ok(s),
|
s @ Stdio::Raw(_) => Ok(s),
|
||||||
}
|
}
|
||||||
@ -430,12 +430,10 @@ impl Process {
|
|||||||
Stdio::Inherit => Ok(()),
|
Stdio::Inherit => Ok(()),
|
||||||
Stdio::Raw(fd) => cvt_r(|| libc::dup2(fd, dst)).map(|_| ()),
|
Stdio::Raw(fd) => cvt_r(|| libc::dup2(fd, dst)).map(|_| ()),
|
||||||
|
|
||||||
// If a stdio file descriptor is set to be ignored, we open up
|
// Open up a reference to /dev/null with appropriate read/write
|
||||||
// /dev/null into that file descriptor. Otherwise, the first
|
// permissions and then move it into the correct location via
|
||||||
// file descriptor opened up in the child would be numbered as
|
// `dup2`.
|
||||||
// one of the stdio file descriptors, which is likely to wreak
|
Stdio::Null => {
|
||||||
// havoc.
|
|
||||||
Stdio::None => {
|
|
||||||
let mut opts = OpenOptions::new();
|
let mut opts = OpenOptions::new();
|
||||||
opts.read(dst == libc::STDIN_FILENO);
|
opts.read(dst == libc::STDIN_FILENO);
|
||||||
opts.write(dst != libc::STDIN_FILENO);
|
opts.write(dst != libc::STDIN_FILENO);
|
||||||
@ -590,7 +588,7 @@ mod tests {
|
|||||||
|
|
||||||
let cat = t!(Process::spawn(&cmd, Stdio::Raw(stdin_read.raw()),
|
let cat = t!(Process::spawn(&cmd, Stdio::Raw(stdin_read.raw()),
|
||||||
Stdio::Raw(stdout_write.raw()),
|
Stdio::Raw(stdout_write.raw()),
|
||||||
Stdio::None));
|
Stdio::Null));
|
||||||
drop(stdin_read);
|
drop(stdin_read);
|
||||||
drop(stdout_write);
|
drop(stdout_write);
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ pub struct Process {
|
|||||||
|
|
||||||
pub enum Stdio {
|
pub enum Stdio {
|
||||||
Inherit,
|
Inherit,
|
||||||
None,
|
Null,
|
||||||
Raw(c::HANDLE),
|
Raw(c::HANDLE),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,11 +386,10 @@ impl Stdio {
|
|||||||
RawHandle::new(handle).duplicate(0, true, c::DUPLICATE_SAME_ACCESS)
|
RawHandle::new(handle).duplicate(0, true, c::DUPLICATE_SAME_ACCESS)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Similarly to unix, we don't actually leave holes for the
|
// Open up a reference to NUL with appropriate read/write
|
||||||
// stdio file descriptors, but rather open up /dev/null
|
// permissions as well as the ability to be inherited to child
|
||||||
// equivalents. These equivalents are drawn from libuv's
|
// processes (as this is about to be inherited).
|
||||||
// windows process spawning.
|
Stdio::Null => {
|
||||||
Stdio::None => {
|
|
||||||
let size = mem::size_of::<c::SECURITY_ATTRIBUTES>();
|
let size = mem::size_of::<c::SECURITY_ATTRIBUTES>();
|
||||||
let mut sa = c::SECURITY_ATTRIBUTES {
|
let mut sa = c::SECURITY_ATTRIBUTES {
|
||||||
nLength: size as c::DWORD,
|
nLength: size as c::DWORD,
|
||||||
|
Loading…
Reference in New Issue
Block a user