Commit 55ca3a51 by Jeff Gilbert Committed by Commit Bot

Use execv instead of execve w/ environ.

Some platforms don't want us messing with environ, and these seem to be equivalent. Bug: angleproject:3506 Change-Id: I66804e8accc30421c1cd32c0eda750500e3ecb60 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1646887Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent ec57a240
...@@ -16,10 +16,6 @@ ...@@ -16,10 +16,6 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
// On BSDs (including mac), environ is not declared anywhere:
// https://stackoverflow.com/a/31347357/912144
extern char **environ;
namespace angle namespace angle
{ {
...@@ -158,7 +154,7 @@ bool RunApp(const std::vector<const char *> &args, ...@@ -158,7 +154,7 @@ bool RunApp(const std::vector<const char *> &args,
} }
} }
// Execute the application, which doesn't return unless failed. Note: execve takes argv as // Execute the application, which doesn't return unless failed. Note: execv takes argv as
// `char * const *` for historical reasons. It is safe to const_cast it: // `char * const *` for historical reasons. It is safe to const_cast it:
// //
// http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html // http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
...@@ -171,7 +167,7 @@ bool RunApp(const std::vector<const char *> &args, ...@@ -171,7 +167,7 @@ bool RunApp(const std::vector<const char *> &args,
// modify either the array of pointers or the characters to which the function points, but // modify either the array of pointers or the characters to which the function points, but
// this would disallow existing correct code. Instead, only the array of pointers is noted // this would disallow existing correct code. Instead, only the array of pointers is noted
// as constant. // as constant.
execve(args[0], const_cast<char *const *>(args.data()), environ); execv(args[0], const_cast<char *const *>(args.data()));
_exit(errno); _exit(errno);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment