about summary refs log tree commit diff
path: root/lib/libsystem.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libsystem.c')
-rw-r--r--lib/libsystem.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libsystem.c b/lib/libsystem.c
index 4581aa66..31c23bf6 100644
--- a/lib/libsystem.c
+++ b/lib/libsystem.c
@@ -49,11 +49,12 @@ execProgram(const char *  const progName,
 -----------------------------------------------------------------------------*/
     int stdinSaveFd, stdoutSaveFd;
     int rc;
+    int execErrno;
 
     /* Make stdinFd Standard Input.
        Make stdoutFd Standard Output.
     */
-    stdinSaveFd = dup(STDIN);
+    stdinSaveFd  = dup(STDIN);
     stdoutSaveFd = dup(STDOUT);
     
     close(STDIN);
@@ -64,6 +65,8 @@ execProgram(const char *  const progName,
 
     rc = execvp(progName, (char **)argArray);
 
+    execErrno = errno;
+
     close(STDIN);
     close(STDOUT);
     dup2(stdinSaveFd, STDIN);
@@ -75,7 +78,7 @@ execProgram(const char *  const progName,
         pm_error("Unable to exec '%s' "
                  "(i.e. the program did not run at all).  "
                  "execvp() errno=%d (%s)",
-                 progName, errno, strerror(errno));
+                 progName, execErrno, strerror(execErrno));
     else
         pm_error("INTERNAL ERROR.  execvp() returns, but does not fail.");
 }