mirror of
https://github.com/FAUSheppy/colorredstderr-mirror
synced 2025-12-06 07:01:38 +01:00
Restore environment for execvpe() if the exec fails.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user