From 888329233bb95db64555296d867f3507b40fedd1 Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Fri, 15 May 2020 12:08:39 +0300 Subject: [PATCH] LibC: Fix execvp() errno Of course, using dbg() in the middle will change errno (most likely, reset it to zero). --- Libraries/LibC/unistd.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Libraries/LibC/unistd.cpp b/Libraries/LibC/unistd.cpp index 03c44bd060..da52fa5fd4 100644 --- a/Libraries/LibC/unistd.cpp +++ b/Libraries/LibC/unistd.cpp @@ -135,7 +135,9 @@ int execvpe(const char* filename, char* const argv[], char* const envp[]) int execvp(const char* filename, char* const argv[]) { int rc = execvpe(filename, argv, environ); - dbg() << "execvp() about to return " << rc << " with errno=" << errno; + int saved_errno = errno; + dbg() << "execvp() about to return " << rc << " with errno=" << saved_errno; + errno = saved_errno; return rc; }