From 9ad684229e7cf2f0b3c6068b2122701d167a5794 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 12 Sep 2004 18:05:37 +0000 Subject: Update. * posix/spawn.h [__USE_GNU]: Define POSIX_SPAWN_USEVFORK. * posix/spawnattr_setflags.c: Check whether any unknown bit is set in FLAGS parameter and fail if this is the case. * sysdeps/posix/spawni.c: Use vfork if POSIX_SPAWN_USEVFORK flag is set. --- sysdeps/posix/spawni.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'sysdeps/posix') diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c index f65a0957a7..69106c480e 100644 --- a/sysdeps/posix/spawni.c +++ b/sysdeps/posix/spawni.c @@ -1,5 +1,5 @@ /* Guts of POSIX spawn interface. Generic POSIX.1 version. - Copyright (C) 2000,01,02, 2003 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -76,10 +76,16 @@ __spawni (pid_t *pid, const char *file, char *path, *p, *name; size_t len; size_t pathlen; - short int flags; + + /* Do this once. */ + short int flags = attrp == NULL ? 0 : attrp->__flags; /* Generate the new process. */ - new_pid = __fork (); + if (flags & POSIX_SPAWN_USEVFORK) + new_pid = __vfork (); + else + new_pid = __fork (); + if (new_pid != 0) { if (new_pid < 0) @@ -92,9 +98,6 @@ __spawni (pid_t *pid, const char *file, return 0; } - /* Do this once. */ - flags = attrp == NULL ? 0 : attrp->__flags; - /* Set signal mask. */ if ((flags & POSIX_SPAWN_SETSIGMASK) != 0 && __sigprocmask (SIG_SETMASK, &attrp->__ss, NULL) != 0) -- cgit 1.4.1