@@ -81,11 +81,11 @@ impl Client {
8181 Ok ( Client :: from_fds ( pipes[ 0 ] , pipes[ 1 ] ) )
8282 }
8383
84- pub unsafe fn open ( s : & str ) -> io:: Result < Client > {
84+ pub unsafe fn open ( s : & str , check_pipe : bool ) -> io:: Result < Client > {
8585 if let Some ( client) = Self :: from_fifo ( s) ? {
8686 return Ok ( client) ;
8787 }
88- if let Some ( client) = Self :: from_pipe ( s) ? {
88+ if let Some ( client) = Self :: from_pipe ( s, check_pipe ) ? {
8989 return Ok ( client) ;
9090 }
9191 Err ( io:: Error :: new (
@@ -111,7 +111,7 @@ impl Client {
111111 }
112112
113113 /// `--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 > > {
115115 let mut parts = s. splitn ( 2 , ',' ) ;
116116 let read = parts. next ( ) . unwrap ( ) ;
117117 let write = match parts. next ( ) {
@@ -133,8 +133,8 @@ impl Client {
133133 // If we're called from `make` *without* the leading + on our rule
134134 // then we'll have `MAKEFLAGS` env vars but won't actually have
135135 // 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 ) ?;
138138 drop ( set_cloexec ( read, true ) ) ;
139139 drop ( set_cloexec ( write, true ) ) ;
140140 Ok ( Some ( Client :: from_fds ( read, write) ) )
@@ -386,9 +386,8 @@ impl Helper {
386386 }
387387}
388388
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 {
392391 let mut stat = mem:: zeroed ( ) ;
393392 if libc:: fstat ( fd, & mut stat) == -1 {
394393 Err ( io:: Error :: last_os_error ( ) )
@@ -404,9 +403,7 @@ fn check_fd(fd: c_int) -> io::Result<()> {
404403 }
405404 Err ( io:: Error :: last_os_error ( ) ) //
406405 }
407- }
408- #[ cfg( feature = "do_not_check_pipe" ) ]
409- unsafe {
406+ } else {
410407 match libc:: fcntl ( fd, libc:: F_GETFD ) {
411408 r if r == -1 => Err ( io:: Error :: new (
412409 io:: ErrorKind :: InvalidData ,
0 commit comments