File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -49,13 +49,19 @@ impl FileDesc {
49
49
}
50
50
51
51
pub fn set_cloexec ( & self ) -> io:: Result < ( ) > {
52
- :: sys_common:: util:: dumb_print ( format_args ! ( "{}: set cloexec\n " , self . fd) ) ;
53
- unimplemented ! ( ) ;
52
+ let mut flags = cvt ( libc:: fcntl ( self . fd , libc:: F_GETFL , 0 ) ) ?;
53
+ flags |= libc:: O_CLOEXEC ;
54
+ cvt ( libc:: fcntl ( self . fd , libc:: F_SETFL , flags) ) . and ( Ok ( ( ) ) )
54
55
}
55
56
56
- pub fn set_nonblocking ( & self , _nonblocking : bool ) -> io:: Result < ( ) > {
57
- :: sys_common:: util:: dumb_print ( format_args ! ( "{}: set nonblocking\n " , self . fd) ) ;
58
- unimplemented ! ( ) ;
57
+ pub fn set_nonblocking ( & self , nonblocking : bool ) -> io:: Result < ( ) > {
58
+ let mut flags = cvt ( libc:: fcntl ( self . fd , libc:: F_GETFL , 0 ) ) ?;
59
+ if nonblocking {
60
+ flags |= libc:: O_NONBLOCK ;
61
+ } else {
62
+ flags &= !libc:: O_NONBLOCK ;
63
+ }
64
+ cvt ( libc:: fcntl ( self . fd , libc:: F_SETFL , flags) ) . and ( Ok ( ( ) ) )
59
65
}
60
66
61
67
pub fn duplicate ( & self ) -> io:: Result < FileDesc > {
You can’t perform that action at this time.
0 commit comments