mirror of
https://github.com/fluencelabs/musl
synced 2025-06-27 13:41:57 +00:00
use vfork if possible in posix_spawn
vfork is implemented as the fork syscall (with no atfork handlers run) on archs where it is not available, so this change does not introduce any change in behavior or regression for such archs.
This commit is contained in:
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
|
pid_t __vfork(void);
|
||||||
|
|
||||||
int __posix_spawnx(pid_t *restrict res, const char *restrict path,
|
int __posix_spawnx(pid_t *restrict res, const char *restrict path,
|
||||||
int (*exec)(const char *, char *const *),
|
int (*exec)(const char *, char *const *),
|
||||||
const posix_spawn_file_actions_t *fa,
|
const posix_spawn_file_actions_t *fa,
|
||||||
@ -22,7 +24,7 @@ int __posix_spawnx(pid_t *restrict res, const char *restrict path,
|
|||||||
if (!attr) attr = &dummy_attr;
|
if (!attr) attr = &dummy_attr;
|
||||||
|
|
||||||
sigprocmask(SIG_BLOCK, (void *)(uint64_t []){-1}, &oldmask);
|
sigprocmask(SIG_BLOCK, (void *)(uint64_t []){-1}, &oldmask);
|
||||||
pid = __syscall(SYS_fork);
|
pid = __vfork();
|
||||||
|
|
||||||
if (pid) {
|
if (pid) {
|
||||||
sigprocmask(SIG_SETMASK, &oldmask, 0);
|
sigprocmask(SIG_SETMASK, &oldmask, 0);
|
||||||
|
Reference in New Issue
Block a user