aboutsummaryrefslogtreecommitdiff
path: root/gold/descriptors.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2011-04-22 23:20:28 +0000
committerIan Lance Taylor <ian@airs.com>2011-04-22 23:20:28 +0000
commitd0a9ace301659a82d936cfba740564f6a9ec288a (patch)
treeb47543709a0e13dfcadd65e00d27a60130bfca4d /gold/descriptors.cc
parent94a3fc8b837eb39007fa4e82120f60ec9429317d (diff)
downloadgdb-d0a9ace301659a82d936cfba740564f6a9ec288a.zip
gdb-d0a9ace301659a82d936cfba740564f6a9ec288a.tar.gz
gdb-d0a9ace301659a82d936cfba740564f6a9ec288a.tar.bz2
* descriptors.cc (set_close_on_exec): New function.
(Descriptors::open): Use set_close_on_exec. * output.cc (S_ISLNK): Define if not defined.
Diffstat (limited to 'gold/descriptors.cc')
-rw-r--r--gold/descriptors.cc19
1 files changed, 14 insertions, 5 deletions
diff --git a/gold/descriptors.cc b/gold/descriptors.cc
index db8ad67..2ab0d5c 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 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// 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)
+{
+// Mingw does not define F_SETFD.
+#ifdef F_SETFD
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
#endif
+}
namespace gold
{
@@ -133,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_);