about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-09-12 18:05:37 +0000
committerUlrich Drepper <drepper@redhat.com>2004-09-12 18:05:37 +0000
commit9ad684229e7cf2f0b3c6068b2122701d167a5794 (patch)
tree74e661e3991005d7fb582984a493b5b918f11189
parentcf244b74a04435b6954d5499a09fa97a628bc3ab (diff)
downloadglibc-9ad684229e7cf2f0b3c6068b2122701d167a5794.tar.gz
glibc-9ad684229e7cf2f0b3c6068b2122701d167a5794.tar.xz
glibc-9ad684229e7cf2f0b3c6068b2122701d167a5794.zip
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.
-rw-r--r--ChangeLog6
-rw-r--r--posix/spawn.h5
-rw-r--r--posix/spawnattr_setflags.c15
-rw-r--r--sysdeps/posix/spawni.c15
4 files changed, 33 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 8fcfae681a..281d366aad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2004-09-12  Ulrich Drepper  <drepper@redhat.com>
 
+	* 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.
+
 	* nscd/pwdcache.c (cache_addpw): Sync also negative results to disk.
 	* nscd/grpcache.c (cache_addgr): Likewise.
 	* nscd/hstcache.c (cache_addhst): Likewise.
diff --git a/posix/spawn.h b/posix/spawn.h
index 09b1e9f8e4..ff77fcc8f9 100644
--- a/posix/spawn.h
+++ b/posix/spawn.h
@@ -1,5 +1,5 @@
 /* Definitions for POSIX spawn interface.
-   Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2000, 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
@@ -57,6 +57,9 @@ typedef struct
 #define POSIX_SPAWN_SETSIGMASK		0x08
 #define POSIX_SPAWN_SETSCHEDPARAM	0x10
 #define POSIX_SPAWN_SETSCHEDULER	0x20
+#ifdef __USE_GNU
+# define POSIX_SPAWN_USEVFORK		0x40
+#endif
 
 
 __BEGIN_DECLS
diff --git a/posix/spawnattr_setflags.c b/posix/spawnattr_setflags.c
index 3618efab45..0c3f5d20b7 100644
--- a/posix/spawnattr_setflags.c
+++ b/posix/spawnattr_setflags.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 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
@@ -16,13 +16,26 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <errno.h>
 #include <spawn.h>
 #include <string.h>
 
+#define ALL_FLAGS (POSIX_SPAWN_RESETIDS					      \
+		   | POSIX_SPAWN_SETPGROUP				      \
+		   | POSIX_SPAWN_SETSIGDEF				      \
+		   | POSIX_SPAWN_SETSIGMASK				      \
+		   | POSIX_SPAWN_SETSCHEDPARAM				      \
+		   | POSIX_SPAWN_SETSCHEDULER				      \
+		   | POSIX_SPAWN_USEVFORK)
+
 /* Store flags in the attribute structure.  */
 int
 posix_spawnattr_setflags (posix_spawnattr_t *attr, short int flags)
 {
+  /* Check no invalid bits are set.  */
+  if (flags & ~ALL_FLAGS)
+    return EINVAL;
+
   /* Store the flag word.  */
   attr->__flags = flags;
 
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)