use vfork if possible in posix_spawn
authorRich Felker <dalias@aerifal.cx>
Fri, 14 Sep 2012 19:32:51 +0000 (15:32 -0400)
committerRich Felker <dalias@aerifal.cx>
Fri, 14 Sep 2012 19:32:51 +0000 (15:32 -0400)
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.

src/process/posix_spawn.c

index 1120be0..604756e 100644 (file)
@@ -8,6 +8,8 @@
 
 extern char **environ;
 
+pid_t __vfork(void);
+
 int __posix_spawnx(pid_t *restrict res, const char *restrict path,
        int (*exec)(const char *, char *const *),
        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;
 
        sigprocmask(SIG_BLOCK, (void *)(uint64_t []){-1}, &oldmask);
-       pid = __syscall(SYS_fork);
+       pid = __vfork();
 
        if (pid) {
                sigprocmask(SIG_SETMASK, &oldmask, 0);