]> granicus.if.org Git - apache/commitdiff
Add ap_spawnvp for thread safety.
authorRoy T. Fielding <fielding@apache.org>
Thu, 26 Aug 1999 18:06:13 +0000 (18:06 +0000)
committerRoy T. Fielding <fielding@apache.org>
Thu, 26 Aug 1999 18:06:13 +0000 (18:06 +0000)
Submitted by: Ryan Bloom, Manoj Kasichainula

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@83798 13f79535-47bb-0310-9956-ffa450edef68

os/unix/os-inline.c
os/unix/os.h

index 54ff49a63915b82437ffbb9375bc6b7a9fd6ae51..8018bc7b92f0a5b477d21b664671e133a413ac9c 100644 (file)
@@ -16,6 +16,7 @@
  * INLINE will _not_ be set so we can use this to test if we are
  * compiling this source file.  
  */
+#include <unistd.h>
 
 #ifndef INLINE
 #define INLINE
@@ -29,3 +30,20 @@ INLINE int ap_os_is_path_absolute(const char *file)
 {
   return file[0] == '/';
 }
+
+INLINE int ap_spawnvp(const char *file, char *const argv[])
+{
+    int pid;
+
+    if ((pid = fork()) == -1) {
+        return pid;
+    } else if (pid == 0) {
+        if (execvp(file, argv) == -1)
+            return -1;
+        else
+            return -1;  /* If we get, we have a real error, but this keeps
+                           us from getting a warning during compile time. */
+    } else 
+        return pid;
+}
+    
index 6689dfae5c66d5bab4f37f9fb04b0a400a763ff5..54124c77fcb55cdd890eafb2ed68efd50f2fb5d9 100644 (file)
@@ -77,6 +77,8 @@
 #define INLINE extern ap_inline
 
 INLINE int ap_os_is_path_absolute(const char *file);
+/* spawn = fork + exec on unix */
+INLINE int ap_spawnvp(const char *file, char *const argv[]);
 
 #include "os-inline.c"
 
@@ -86,6 +88,7 @@ INLINE int ap_os_is_path_absolute(const char *file);
  * as normal
  */
 extern int ap_os_is_path_absolute(const char *file);
+extern int ap_spawnvp(const char *file, char *const argv[]);
 #endif
 
 /* Other ap_os_ routines not used by this platform */