From: Simon Ruderich Date: Sat, 29 Jun 2013 21:09:05 +0000 (+0200) Subject: Restore environment for execvpe() if the exec fails. X-Git-Tag: 0.1~17 X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=afa1ef98fe940719c7085e93643185c6de94d300;p=coloredstderr%2Fcoloredstderr.git Restore environment for execvpe() if the exec fails. --- diff --git a/src/coloredstderr.c b/src/coloredstderr.c index 15581a6..a78fdd9 100644 --- a/src/coloredstderr.c +++ b/src/coloredstderr.c @@ -646,10 +646,16 @@ HOOK_FUNC_DEF2(int, execvp, char const *, file, char * const *, argv) { #ifdef HAVE_EXECVPE extern char **environ; int execvpe(char const *file, char * const argv[], char * const envp[]) { + int result; + char **old_environ = environ; + /* Fake the environment so we can reuse execvp(). */ environ = (char **)envp; /* execvp() updates the environment. */ - return execvp(file, argv); + result = execvp(file, argv); + + environ = old_environ; + return result; } #endif