Skip to content

Commit 9845e7d

Browse files
committed
Use posix_spawn on musl targets
The posix_spawn had been available in a form suitable for use in a Command implementation since musl 0.9.12. Use it in a preference to a fork when possible, to benefit from CLONE_VM|CLONE_VFORK used there.
1 parent 2ad6187 commit 9845e7d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

library/std/src/sys/unix/process/process_unix.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ impl Command {
252252
#[cfg(not(any(
253253
target_os = "macos",
254254
target_os = "freebsd",
255-
all(target_os = "linux", target_env = "gnu")
255+
all(target_os = "linux", target_env = "gnu"),
256+
all(target_os = "linux", target_env = "musl"),
256257
)))]
257258
fn posix_spawn(
258259
&mut self,
@@ -267,7 +268,8 @@ impl Command {
267268
#[cfg(any(
268269
target_os = "macos",
269270
target_os = "freebsd",
270-
all(target_os = "linux", target_env = "gnu")
271+
all(target_os = "linux", target_env = "gnu"),
272+
all(target_os = "linux", target_env = "musl"),
271273
))]
272274
fn posix_spawn(
273275
&mut self,
@@ -297,10 +299,10 @@ impl Command {
297299
}
298300
}
299301

300-
// Solaris and glibc 2.29+ can set a new working directory, and maybe
301-
// others will gain this non-POSIX function too. We'll check for this
302-
// weak symbol as soon as it's needed, so we can return early otherwise
303-
// to do a manual chdir before exec.
302+
// Solaris, glibc 2.29+, and musl 1.24+ can set a new working directory,
303+
// and maybe others will gain this non-POSIX function too. We'll check
304+
// for this weak symbol as soon as it's needed, so we can return early
305+
// otherwise to do a manual chdir before exec.
304306
weak! {
305307
fn posix_spawn_file_actions_addchdir_np(
306308
*mut libc::posix_spawn_file_actions_t,

0 commit comments

Comments
 (0)