ProcessLauncherPosixFork: Fetch errno early

I was seeing some unlikely errno values here. I am not sure if this will
help, but it nontheless seems like a good idea to stash errno value
before issuing other syscalls.

llvm-svn: 305778
This commit is contained in:
Pavel Labath 2017-06-20 08:11:37 +00:00
parent 9a90b68707
commit 6c5c542986
1 changed files with 4 additions and 4 deletions

View File

@ -52,10 +52,10 @@ static void FixupEnvironment(Args &env) {
static void LLVM_ATTRIBUTE_NORETURN ExitWithError(int error_fd,
const char *operation) {
std::ostringstream os;
os << operation << " failed: " << strerror(errno);
write(error_fd, os.str().data(), os.str().size());
close(error_fd);
int err = errno;
llvm::raw_fd_ostream os(error_fd, true);
os << operation << " failed: " << llvm::sys::StrError(err);
os.flush();
_exit(1);
}