@@ -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