@@ -235,7 +235,8 @@ impl Command {
235
235
io:: Error :: last_os_error ( )
236
236
}
237
237
238
- #[ cfg( not( any( target_os = "macos" , target_os = "freebsd" ) ) ) ]
238
+ #[ cfg( not( any( target_os = "macos" , target_os = "freebsd" ,
239
+ all( target_os = "linux" , target_env = "gnu" ) ) ) ) ]
239
240
fn posix_spawn ( & mut self , _: & ChildPipes , _: Option < & CStringArray > )
240
241
-> io:: Result < Option < Process > >
241
242
{
@@ -244,7 +245,8 @@ impl Command {
244
245
245
246
// Only support platforms for which posix_spawn() can return ENOENT
246
247
// directly.
247
- #[ cfg( any( target_os = "macos" , target_os = "freebsd" ) ) ]
248
+ #[ cfg( any( target_os = "macos" , target_os = "freebsd" ,
249
+ all( target_os = "linux" , target_env = "gnu" ) ) ) ]
248
250
fn posix_spawn ( & mut self , stdio : & ChildPipes , envp : Option < & CStringArray > )
249
251
-> io:: Result < Option < Process > >
250
252
{
@@ -258,6 +260,18 @@ impl Command {
258
260
return Ok ( None )
259
261
}
260
262
263
+ // Only glibc 2.24+ posix_spawn() supports returning ENOENT directly.
264
+ #[ cfg( all( target_os = "linux" , target_env = "gnu" ) ) ]
265
+ {
266
+ if let Some ( version) = sys:: os:: glibc_version ( ) {
267
+ if version < ( 2 , 24 ) {
268
+ return Ok ( None )
269
+ }
270
+ } else {
271
+ return Ok ( None )
272
+ }
273
+ }
274
+
261
275
let mut p = Process { pid : 0 , status : None } ;
262
276
263
277
struct PosixSpawnFileActions ( libc:: posix_spawn_file_actions_t ) ;
0 commit comments