From 67f618433366316dca8e8c5cdc08e106e268c81a Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 3 Jan 2013 20:16:17 -0800 Subject: Enable FD_CLOEXEC for non-blocking pipes. --- pym/portage/util/_async/PipeLogger.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'pym/portage/util/_async') 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) -- cgit v1.2.3-1-g7c22