File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -14,13 +14,18 @@ pub fn set_non_blocking(stderr: &mut ChildStderr) -> Result<(), Error> {
14
14
{
15
15
use std:: os:: unix:: io:: AsRawFd ;
16
16
let fd = stderr. as_raw_fd ( ) ;
17
- debug_assert_eq ! (
18
- unsafe { libc:: fcntl( fd, libc:: F_GETFL , 0 ) } ,
19
- 0 ,
20
- "stderr should have no flags set"
21
- ) ;
17
+ let flags = unsafe { libc:: fcntl ( fd, libc:: F_GETFL , 0 ) } ;
18
+ if flags == -1 {
19
+ return Err ( Error :: new (
20
+ ErrorKind :: IOError ,
21
+ format ! (
22
+ "Failed to get flags for child stderr: {}" ,
23
+ std:: io:: Error :: last_os_error( )
24
+ ) ,
25
+ ) ) ;
26
+ }
22
27
23
- if unsafe { libc:: fcntl ( fd, libc:: F_SETFL , libc:: O_NONBLOCK ) } != 0 {
28
+ if unsafe { libc:: fcntl ( fd, libc:: F_SETFL , flags | libc:: O_NONBLOCK ) } == - 1 {
24
29
return Err ( Error :: new (
25
30
ErrorKind :: IOError ,
26
31
format ! (
You can’t perform that action at this time.
0 commit comments