@@ -42,30 +42,17 @@ fn pipe2(flags: nix::fcntl::OFlag) -> nix::Result<(RawFd, RawFd)> {
42
42
43
43
let pipe = unistd:: pipe ( ) ?;
44
44
45
- let mut res = Ok ( 0 ) ;
46
-
47
45
if flags. contains ( OFlag :: O_CLOEXEC ) {
48
- res = res
49
- . and_then ( |_| fcntl ( & pipe. 0 , FcntlArg :: F_SETFD ( FdFlag :: FD_CLOEXEC ) ) )
50
- . and_then ( |_| fcntl ( & pipe. 1 , FcntlArg :: F_SETFD ( FdFlag :: FD_CLOEXEC ) ) ) ;
46
+ fcntl ( & pipe. 0 , FcntlArg :: F_SETFD ( FdFlag :: FD_CLOEXEC ) ) ?;
47
+ fcntl ( & pipe. 1 , FcntlArg :: F_SETFD ( FdFlag :: FD_CLOEXEC ) ) ?;
51
48
}
52
49
53
50
if flags. contains ( OFlag :: O_NONBLOCK ) {
54
- res = res
55
- . and_then ( |_| fcntl ( & pipe. 0 , FcntlArg :: F_SETFL ( OFlag :: O_NONBLOCK ) ) )
56
- . and_then ( |_| fcntl ( & pipe. 1 , FcntlArg :: F_SETFL ( OFlag :: O_NONBLOCK ) ) ) ;
51
+ fcntl ( & pipe. 0 , FcntlArg :: F_SETFL ( OFlag :: O_NONBLOCK ) ) ?;
52
+ fcntl ( & pipe. 1 , FcntlArg :: F_SETFL ( OFlag :: O_NONBLOCK ) ) ?;
57
53
}
58
54
59
- let pipe = ( pipe. 0 . into_raw_fd ( ) , pipe. 1 . into_raw_fd ( ) ) ;
60
-
61
- match res {
62
- Ok ( _) => Ok ( pipe) ,
63
- Err ( e) => {
64
- let _ = unistd:: close ( pipe. 0 ) ;
65
- let _ = unistd:: close ( pipe. 1 ) ;
66
- Err ( e)
67
- }
68
- }
55
+ Ok ( ( pipe. 0 . into_raw_fd ( ) , pipe. 1 . into_raw_fd ( ) ) )
69
56
}
70
57
71
58
#[ inline]
@@ -104,7 +91,10 @@ pub unsafe fn init_os_handler(overwrite: bool) -> Result<(), Error> {
104
91
} ;
105
92
106
93
// Make sure we never block on write in the os handler.
107
- if let Err ( e) = fcntl:: fcntl ( BorrowedFd :: borrow_raw ( PIPE . 1 ) , fcntl:: FcntlArg :: F_SETFL ( fcntl:: OFlag :: O_NONBLOCK ) ) {
94
+ if let Err ( e) = fcntl:: fcntl (
95
+ BorrowedFd :: borrow_raw ( PIPE . 1 ) ,
96
+ fcntl:: FcntlArg :: F_SETFL ( fcntl:: OFlag :: O_NONBLOCK ) ,
97
+ ) {
108
98
return Err ( close_pipe ( e) ) ;
109
99
}
110
100
0 commit comments