From: Roy Marples Date: Sat, 2 Feb 2008 18:08:49 +0000 (+0000) Subject: Of course, BSD systems don't have posix_spawn yet :/ X-Git-Tag: v3.2.3~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=376d7a6ec54736eb4b1304da6bc050833134242f;p=thirdparty%2Fdhcpcd.git Of course, BSD systems don't have posix_spawn yet :/ --- diff --git a/configure.c b/configure.c index c7591c18..71282bb7 100644 --- a/configure.c +++ b/configure.c @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -40,11 +41,18 @@ #include #include #include -#include #include #include #include +#ifndef BSD +#define HAVE_POSIX_SPAWN +#endif + +#ifdef HAVE_POSIX_SPAWN +#include +#endif + #include "config.h" #include "common.h" #include "configure.h" @@ -93,6 +101,9 @@ static int exec_cmd (const char *cmd, const char *args, ...) char **argv; int n = 1; int ret; +#ifndef HAVE_POSIX_SPAWN + pid_t pid; +#endif va_start (va, args); while (va_arg (va, char *) != NULL) @@ -108,11 +119,26 @@ static int exec_cmd (const char *cmd, const char *args, ...) n++; va_end (va); +#ifdef HAVE_POSIX_SPAWN errno = 0; ret = posix_spawnp (NULL, argv[0], NULL, NULL, argv, environ); - if (ret != 0 || errno != 0) + if (ret != 0 || errno != 0) { logger (LOG_ERR, "error executing \"%s\": %s", cmd, strerror (errno)); + ret = -1; + } +#else + if ((pid = vfork ()) == 0) { + if (execvp (cmd, argv) && errno != ENOENT) + logger (LOG_ERR, "error executing \"%s\": %s", + cmd, strerror (errno)); + _exit (0); + } else if (pid == -1) { + logger (LOG_ERR, "vfork: %s", strerror (errno)); + ret = -1; + } +#endif + free (argv); return (ret); }