aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-19 17:02:10 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-21 14:58:15 +0100
commit7c6ec0fd835409d0ab1bca8924ce4ac5916b4e25 (patch)
tree5c57bcf6032937f40c5f97d4381b13a578905502
parent417f226c87b91f31319096fec27d24d506318cf8 (diff)
downloadpaludis-7c6ec0fd835409d0ab1bca8924ce4ac5916b4e25.tar.gz
paludis-7c6ec0fd835409d0ab1bca8924ce4ac5916b4e25.tar.xz
Let Pipe set O_CLOEXEC itself
-rw-r--r--paludis/util/pipe.cc11
-rw-r--r--paludis/util/pipe.hh4
2 files changed, 13 insertions, 2 deletions
diff --git a/paludis/util/pipe.cc b/paludis/util/pipe.cc
index 88f130f..fdb42f9 100644
--- a/paludis/util/pipe.cc
+++ b/paludis/util/pipe.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2010 Ciaran McCreesh
* Copyright (c) 2009 David Leverton
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -22,6 +22,7 @@
#include <paludis/util/exception.hh>
#include <paludis/util/log.hh>
#include <unistd.h>
+#include <fcntl.h>
using namespace paludis;
@@ -36,6 +37,14 @@ Pipe::Pipe()
<< write_fd() << "'";
}
+Pipe::Pipe(const bool close_exec)
+{
+ /* if your os doesn't have pipe2, you'll need to make this use a big nasty
+ * global mutex along with everything that calls fork(). */
+ if (-1 == pipe2(_fds, close_exec ? O_CLOEXEC : 0))
+ throw InternalError(PALUDIS_HERE, "pipe(2) failed");
+}
+
Pipe::~Pipe()
{
}
diff --git a/paludis/util/pipe.hh b/paludis/util/pipe.hh
index ae0184e..928c889 100644
--- a/paludis/util/pipe.hh
+++ b/paludis/util/pipe.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2010 Ciaran McCreesh
* Copyright (c) 2009 David Leverton
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -50,6 +50,8 @@ namespace paludis
Pipe();
+ explicit Pipe(const bool close_exec);
+
virtual ~Pipe();
///\}