@@ -41,22 +41,23 @@ fn pipe2(flags: nix::fcntl::OFlag) -> nix::Result<(RawFd, RawFd)> {
41
41
use nix:: fcntl:: { fcntl, FcntlArg , FdFlag , OFlag } ;
42
42
43
43
let pipe = unistd:: pipe ( ) ?;
44
- let pipe = ( pipe. 0 . into_raw_fd ( ) , pipe. 1 . into_raw_fd ( ) ) ;
45
44
46
45
let mut res = Ok ( 0 ) ;
47
46
48
47
if flags. contains ( OFlag :: O_CLOEXEC ) {
49
48
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 ) ) ) ;
52
51
}
53
52
54
53
if flags. contains ( OFlag :: O_NONBLOCK ) {
55
54
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 ) ) ) ;
58
57
}
59
58
59
+ let pipe = ( pipe. 0 . into_raw_fd ( ) , pipe. 1 . into_raw_fd ( ) ) ;
60
+
60
61
match res {
61
62
Ok ( _) => Ok ( pipe) ,
62
63
Err ( e) => {
@@ -103,7 +104,7 @@ pub unsafe fn init_os_handler(overwrite: bool) -> Result<(), Error> {
103
104
} ;
104
105
105
106
// 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 ) ) {
107
108
return Err ( close_pipe ( e) ) ;
108
109
}
109
110
@@ -177,7 +178,7 @@ pub unsafe fn block_ctrl_c() -> Result<(), CtrlcError> {
177
178
// with std::os::unix::io::FromRawFd, this would handle EINTR
178
179
// and everything for us.
179
180
loop {
180
- match unistd:: read ( PIPE . 0 , & mut buf[ ..] ) {
181
+ match unistd:: read ( BorrowedFd :: borrow_raw ( PIPE . 0 ) , & mut buf[ ..] ) {
181
182
Ok ( 1 ) => break ,
182
183
Ok ( _) => return Err ( CtrlcError :: System ( io:: ErrorKind :: UnexpectedEof . into ( ) ) ) ,
183
184
Err ( nix:: errno:: Errno :: EINTR ) => { }
0 commit comments