From afa1ef98fe940719c7085e93643185c6de94d300 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sat, 29 Jun 2013 23:09:05 +0200 Subject: [PATCH] Restore environment for execvpe() if the exec fails. --- src/coloredstderr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 -- 2.45.2