aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 88f130f0c..fdb42f919 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 ae0184e2d..928c889ef 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();
///\}