When exec() fails, return 127 instead of errno; the parent process has no way to
authorDaniel Dunbar <daniel@zuster.org>
Tue, 4 Aug 2009 20:32:25 +0000 (20:32 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 4 Aug 2009 20:32:25 +0000 (20:32 +0000)
distinguish that the result is errno, so it can't use it to provide more
information about the error (it also exposes the numeric value of errno).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78098 91177308-0d34-0410-b5e6-96231b3b80d8

lib/System/Unix/Program.inc

index 3a562e45d41d5df83e5c2b506929c3fa5d370ffb..d2baca80025b52d0ce2533d2cb5631dc4cef0c3c 100644 (file)
@@ -197,12 +197,12 @@ Program::Execute(const Path& path,
 
       // Execute!
       if (envp != 0)
-        execve (path.c_str(), (char**)args, (char**)envp);
+        execve(path.c_str(), (char**)args, (char**)envp);
       else
-        execv (path.c_str(), (char**)args);
+        execv(path.c_str(), (char**)args);
       // If the execve() failed, we should exit and let the parent pick up
       // our non-zero exit status.
-      exit (errno);
+      exit(127);
     }
 
     // Parent process: Break out of the switch to do our processing.