X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gold%2Fdescriptors.cc;h=f3f071e32b269feac69082f15c85f580ce0146f0;hb=d180bcbd34b9ed5f0062636786ff31c803c2f735;hp=f4a02d03296caaf2cc1b6eeaf12204785b31ac12;hpb=f3048a1d4770f01625461c6d967a774f5a3f8496;p=deliverable%2Fbinutils-gdb.git diff --git a/gold/descriptors.cc b/gold/descriptors.cc index f4a02d0329..f3f071e32b 100644 --- a/gold/descriptors.cc +++ b/gold/descriptors.cc @@ -1,6 +1,6 @@ // descriptors.cc -- manage file descriptors for gold -// Copyright 2008, 2009 Free Software Foundation, Inc. +// Copyright 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. // Written by Ian Lance Taylor . // This file is part of gold. @@ -34,15 +34,24 @@ #include "descriptors.h" #include "binary-io.h" +// O_CLOEXEC is only available on newer systems. +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif + // Very old systems may not define FD_CLOEXEC. #ifndef FD_CLOEXEC #define FD_CLOEXEC 1 #endif -// O_CLOEXEC is only available on newer systems. -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 +static inline void +set_close_on_exec(int fd ATTRIBUTE_UNUSED) +{ +// Mingw does not define F_SETFD. +#ifdef F_SETFD + fcntl(fd, F_SETFD, FD_CLOEXEC); #endif +} namespace gold { @@ -113,8 +122,7 @@ Descriptors::open(int descriptor, const char* name, int flags, int mode) { Hold_lock hl(*this->lock_); - gold_error(_("file %s was removed during the link"), - this->open_descriptors_[descriptor].name); + gold_error(_("file %s was removed during the link"), name); } errno = ENOENT; @@ -134,7 +142,7 @@ Descriptors::open(int descriptor, const char* name, int flags, int mode) if (O_CLOEXEC == 0 && parameters->options_valid() && parameters->options().has_plugins()) - fcntl(new_descriptor, F_SETFD, FD_CLOEXEC); + set_close_on_exec(new_descriptor); { Hold_optional_lock hl(this->lock_);