Skip to content

Commit 3e5af79

Browse files
BerrysoftDetegr
authored andcommitted
Update nix to 0.30
1 parent b9cf4cf commit 3e5af79

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ readme = "README.md"
1515
rust-version = "1.69.0"
1616

1717
[target.'cfg(unix)'.dependencies]
18-
nix = { version = "0.29", default-features = false, features = ["fs", "signal"]}
18+
nix = { version = "0.30", default-features = false, features = ["fs", "signal"]}
1919

2020
[target.'cfg(windows)'.dependencies]
2121
windows-sys = { version = "0.59", features = ["Win32_Foundation", "Win32_System_Threading", "Win32_Security", "Win32_System_Console"] }

src/platform/unix/mod.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,23 @@ fn pipe2(flags: nix::fcntl::OFlag) -> nix::Result<(RawFd, RawFd)> {
4141
use nix::fcntl::{fcntl, FcntlArg, FdFlag, OFlag};
4242

4343
let pipe = unistd::pipe()?;
44-
let pipe = (pipe.0.into_raw_fd(), pipe.1.into_raw_fd());
4544

4645
let mut res = Ok(0);
4746

4847
if flags.contains(OFlag::O_CLOEXEC) {
4948
res = res
50-
.and_then(|_| fcntl(pipe.0, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC)))
51-
.and_then(|_| fcntl(pipe.1, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC)));
49+
.and_then(|_| fcntl(&pipe.0, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC)))
50+
.and_then(|_| fcntl(&pipe.1, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC)));
5251
}
5352

5453
if flags.contains(OFlag::O_NONBLOCK) {
5554
res = res
56-
.and_then(|_| fcntl(pipe.0, FcntlArg::F_SETFL(OFlag::O_NONBLOCK)))
57-
.and_then(|_| fcntl(pipe.1, FcntlArg::F_SETFL(OFlag::O_NONBLOCK)));
55+
.and_then(|_| fcntl(&pipe.0, FcntlArg::F_SETFL(OFlag::O_NONBLOCK)))
56+
.and_then(|_| fcntl(&pipe.1, FcntlArg::F_SETFL(OFlag::O_NONBLOCK)));
5857
}
5958

59+
let pipe = (pipe.0.into_raw_fd(), pipe.1.into_raw_fd());
60+
6061
match res {
6162
Ok(_) => Ok(pipe),
6263
Err(e) => {
@@ -103,7 +104,7 @@ pub unsafe fn init_os_handler(overwrite: bool) -> Result<(), Error> {
103104
};
104105

105106
// Make sure we never block on write in the os handler.
106-
if let Err(e) = fcntl::fcntl(PIPE.1, fcntl::FcntlArg::F_SETFL(fcntl::OFlag::O_NONBLOCK)) {
107+
if let Err(e) = fcntl::fcntl(BorrowedFd::borrow_raw(PIPE.1), fcntl::FcntlArg::F_SETFL(fcntl::OFlag::O_NONBLOCK)) {
107108
return Err(close_pipe(e));
108109
}
109110

@@ -177,7 +178,7 @@ pub unsafe fn block_ctrl_c() -> Result<(), CtrlcError> {
177178
// with std::os::unix::io::FromRawFd, this would handle EINTR
178179
// and everything for us.
179180
loop {
180-
match unistd::read(PIPE.0, &mut buf[..]) {
181+
match unistd::read(BorrowedFd::borrow_raw(PIPE.0), &mut buf[..]) {
181182
Ok(1) => break,
182183
Ok(_) => return Err(CtrlcError::System(io::ErrorKind::UnexpectedEof.into())),
183184
Err(nix::errno::Errno::EINTR) => {}

0 commit comments

Comments
 (0)