Skip to content

Commit 2d8d2a9

Browse files
committed
fix(fs): use POSIX standard fileno
1 parent 20b765f commit 2d8d2a9

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

compio-driver/src/iocp/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub trait AsRawFd {
5656

5757
/// Construct IO objects from raw fds.
5858
pub trait FromRawFd {
59-
/// Constructs a new IO object from the specified raw fd.
59+
/// Constructs an IO object from the specified raw fd.
6060
///
6161
/// # Safety
6262
///

compio-fs/src/stdio/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cfg_if::cfg_if! {
88
}
99
}
1010

11-
/// Constructs a new handle to the standard input of the current process.
11+
/// Constructs a handle to the standard input of the current process.
1212
///
1313
/// ## Platform specific
1414
/// * Windows: This handle is best used for non-interactive uses, such as when a
@@ -23,7 +23,7 @@ pub fn stdin() -> Stdin {
2323
Stdin::new()
2424
}
2525

26-
/// Constructs a new handle to the standard output of the current process.
26+
/// Constructs a handle to the standard output of the current process.
2727
///
2828
/// Concurrent writes to stdout must be executed with care: Only individual
2929
/// writes to this [`AsyncWrite`] are guaranteed to be intact. In particular
@@ -37,7 +37,7 @@ pub fn stdout() -> Stdout {
3737
Stdout::new()
3838
}
3939

40-
/// Constructs a new handle to the standard output of the current process.
40+
/// Constructs a handle to the standard error of the current process.
4141
///
4242
/// Concurrent writes to stderr must be executed with care: Only individual
4343
/// writes to this [`AsyncWrite`] are guaranteed to be intact. In particular

compio-fs/src/stdio/unix.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{io, mem::ManuallyDrop};
22

33
use compio_buf::{BufResult, IoBuf, IoBufMut};
4-
use compio_driver::{AsRawFd, FromRawFd, RawFd};
4+
use compio_driver::{FromRawFd, RawFd};
55
use compio_io::{AsyncRead, AsyncWrite};
66
use compio_runtime::TryAsRawFd;
77

@@ -14,8 +14,9 @@ pub struct Stdin(ManuallyDrop<Receiver>);
1414

1515
impl Stdin {
1616
pub(crate) fn new() -> Self {
17+
// SAFETY: we don't drop it
1718
Self(ManuallyDrop::new(unsafe {
18-
Receiver::from_raw_fd(io::stdin().as_raw_fd())
19+
Receiver::from_raw_fd(libc::STDIN_FILENO)
1920
}))
2021
}
2122
}
@@ -43,8 +44,9 @@ pub struct Stdout(ManuallyDrop<Sender>);
4344

4445
impl Stdout {
4546
pub(crate) fn new() -> Self {
47+
// SAFETY: we don't drop it
4648
Self(ManuallyDrop::new(unsafe {
47-
Sender::from_raw_fd(io::stdout().as_raw_fd())
49+
Sender::from_raw_fd(libc::STDOUT_FILENO)
4850
}))
4951
}
5052
}
@@ -80,8 +82,9 @@ pub struct Stderr(ManuallyDrop<Sender>);
8082

8183
impl Stderr {
8284
pub(crate) fn new() -> Self {
85+
// SAFETY: we don't drop it
8386
Self(ManuallyDrop::new(unsafe {
84-
Sender::from_raw_fd(io::stderr().as_raw_fd())
87+
Sender::from_raw_fd(libc::STDERR_FILENO)
8588
}))
8689
}
8790
}

0 commit comments

Comments
 (0)