From: Roy T. Fielding Date: Thu, 26 Aug 1999 18:06:13 +0000 (+0000) Subject: Add ap_spawnvp for thread safety. X-Git-Tag: PRE_APR_CHANGES~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=53d7c13e320100a442f75693e5877ed942279f5a;p=apache Add ap_spawnvp for thread safety. Submitted by: Ryan Bloom, Manoj Kasichainula git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@83798 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/os/unix/os-inline.c b/os/unix/os-inline.c index 54ff49a639..8018bc7b92 100644 --- a/os/unix/os-inline.c +++ b/os/unix/os-inline.c @@ -16,6 +16,7 @@ * INLINE will _not_ be set so we can use this to test if we are * compiling this source file. */ +#include #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; +} + diff --git a/os/unix/os.h b/os/unix/os.h index 6689dfae5c..54124c77fc 100644 --- a/os/unix/os.h +++ b/os/unix/os.h @@ -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 */