summaryrefslogtreecommitdiffstats
path: root/pym/portage
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2013-01-03 20:16:17 -0800
committerZac Medico <zmedico@gentoo.org>2013-01-03 20:16:17 -0800
commit67f618433366316dca8e8c5cdc08e106e268c81a (patch)
treeec451083ab5ef091b0b4d64288782cb48e2535ed /pym/portage
parent65a5f14f8b76a250f5df42e57512bfc140543622 (diff)
downloadportage-67f618433366316dca8e8c5cdc08e106e268c81a.tar.gz
portage-67f618433366316dca8e8c5cdc08e106e268c81a.tar.bz2
portage-67f618433366316dca8e8c5cdc08e106e268c81a.zip
Enable FD_CLOEXEC for non-blocking pipes.
Diffstat (limited to 'pym/portage')
-rw-r--r--pym/portage/dbapi/_MergeProcess.py11
-rw-r--r--pym/portage/util/_async/PipeLogger.py12
-rw-r--r--pym/portage/util/_eventloop/EventLoop.py13
3 files changed, 31 insertions, 5 deletions
diff --git a/pym/portage/dbapi/_MergeProcess.py b/pym/portage/dbapi/_MergeProcess.py
index e2534cf9d..1442d56ac 100644
--- a/pym/portage/dbapi/_MergeProcess.py
+++ b/pym/portage/dbapi/_MergeProcess.py
@@ -114,8 +114,17 @@ class MergeProcess(ForkProcess):
"""
elog_reader_fd, elog_writer_fd = os.pipe()
+
+ fcntl_flags = os.O_NONBLOCK
+ try:
+ fcntl.FD_CLOEXEC
+ except AttributeError:
+ pass
+ else:
+ fcntl_flags |= fcntl.FD_CLOEXEC
+
fcntl.fcntl(elog_reader_fd, fcntl.F_SETFL,
- fcntl.fcntl(elog_reader_fd, fcntl.F_GETFL) | os.O_NONBLOCK)
+ fcntl.fcntl(elog_reader_fd, fcntl.F_GETFL) | fcntl_flags)
blockers = None
if self.blockers is not None:
# Query blockers in the main process, since closing
diff --git a/pym/portage/util/_async/PipeLogger.py b/pym/portage/util/_async/PipeLogger.py
index 0905e47f9..376ebfef7 100644
--- a/pym/portage/util/_async/PipeLogger.py
+++ b/pym/portage/util/_async/PipeLogger.py
@@ -1,4 +1,4 @@
-# Copyright 2008-2012 Gentoo Foundation
+# Copyright 2008-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import fcntl
@@ -38,8 +38,16 @@ class PipeLogger(AbstractPollTask):
uid=portage.portage_uid, gid=portage.portage_gid,
mode=0o660)
+ fcntl_flags = os.O_NONBLOCK
+ try:
+ fcntl.FD_CLOEXEC
+ except AttributeError:
+ pass
+ else:
+ fcntl_flags |= fcntl.FD_CLOEXEC
+
fcntl.fcntl(self.input_fd, fcntl.F_SETFL,
- fcntl.fcntl(self.input_fd, fcntl.F_GETFL) | os.O_NONBLOCK)
+ fcntl.fcntl(self.input_fd, fcntl.F_GETFL) | fcntl_flags)
self._reg_id = self.scheduler.io_add_watch(self.input_fd,
self._registered_events, self._output_handler)
diff --git a/pym/portage/util/_eventloop/EventLoop.py b/pym/portage/util/_eventloop/EventLoop.py
index 6c2341bcd..ad64406c0 100644
--- a/pym/portage/util/_eventloop/EventLoop.py
+++ b/pym/portage/util/_eventloop/EventLoop.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2012 Gentoo Foundation
+# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import errno
@@ -308,9 +308,18 @@ class EventLoop(object):
if self._use_signal:
if self._sigchld_read is None:
self._sigchld_read, self._sigchld_write = os.pipe()
+
+ fcntl_flags = os.O_NONBLOCK
+ try:
+ fcntl.FD_CLOEXEC
+ except AttributeError:
+ pass
+ else:
+ fcntl_flags |= fcntl.FD_CLOEXEC
+
fcntl.fcntl(self._sigchld_read, fcntl.F_SETFL,
fcntl.fcntl(self._sigchld_read,
- fcntl.F_GETFL) | os.O_NONBLOCK)
+ fcntl.F_GETFL) | fcntl_flags)
# The IO watch is dynamically registered and unregistered as
# needed, since we don't want to consider it as a valid source