@@ -81,11 +81,11 @@ impl Client {
81
81
Ok ( Client :: from_fds ( pipes[ 0 ] , pipes[ 1 ] ) )
82
82
}
83
83
84
- pub unsafe fn open ( s : & str ) -> io:: Result < Client > {
84
+ pub unsafe fn open ( s : & str , check_pipe : bool ) -> io:: Result < Client > {
85
85
if let Some ( client) = Self :: from_fifo ( s) ? {
86
86
return Ok ( client) ;
87
87
}
88
- if let Some ( client) = Self :: from_pipe ( s) ? {
88
+ if let Some ( client) = Self :: from_pipe ( s, check_pipe ) ? {
89
89
return Ok ( client) ;
90
90
}
91
91
Err ( io:: Error :: new (
@@ -111,7 +111,7 @@ impl Client {
111
111
}
112
112
113
113
/// `--jobserver-auth=R,W`
114
- unsafe fn from_pipe ( s : & str ) -> io:: Result < Option < Client > > {
114
+ unsafe fn from_pipe ( s : & str , check_pipe : bool ) -> io:: Result < Option < Client > > {
115
115
let mut parts = s. splitn ( 2 , ',' ) ;
116
116
let read = parts. next ( ) . unwrap ( ) ;
117
117
let write = match parts. next ( ) {
@@ -133,8 +133,8 @@ impl Client {
133
133
// If we're called from `make` *without* the leading + on our rule
134
134
// then we'll have `MAKEFLAGS` env vars but won't actually have
135
135
// access to the file descriptors.
136
- check_fd ( read) ?;
137
- check_fd ( write) ?;
136
+ check_fd ( read, check_pipe ) ?;
137
+ check_fd ( write, check_pipe ) ?;
138
138
drop ( set_cloexec ( read, true ) ) ;
139
139
drop ( set_cloexec ( write, true ) ) ;
140
140
Ok ( Some ( Client :: from_fds ( read, write) ) )
@@ -386,9 +386,8 @@ impl Helper {
386
386
}
387
387
}
388
388
389
- fn check_fd ( fd : c_int ) -> io:: Result < ( ) > {
390
- #[ cfg( not( feature = "do_not_check_pipe" ) ) ]
391
- unsafe {
389
+ unsafe fn check_fd ( fd : c_int , check_pipe : bool ) -> io:: Result < ( ) > {
390
+ if check_pipe {
392
391
let mut stat = mem:: zeroed ( ) ;
393
392
if libc:: fstat ( fd, & mut stat) == -1 {
394
393
Err ( io:: Error :: last_os_error ( ) )
@@ -404,9 +403,7 @@ fn check_fd(fd: c_int) -> io::Result<()> {
404
403
}
405
404
Err ( io:: Error :: last_os_error ( ) ) //
406
405
}
407
- }
408
- #[ cfg( feature = "do_not_check_pipe" ) ]
409
- unsafe {
406
+ } else {
410
407
match libc:: fcntl ( fd, libc:: F_GETFD ) {
411
408
r if r == -1 => Err ( io:: Error :: new (
412
409
io:: ErrorKind :: InvalidData ,
0 commit comments