-# Copyright 2010-2012 Gentoo Foundation
+# Copyright 2010-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import dummy_threading
self._files = {}
self._files['pipe_in'] = in_pr
self._files['pipe_out'] = out_pw
+
+ fcntl_flags = os.O_NONBLOCK
+ try:
+ fcntl.FD_CLOEXEC
+ except AttributeError:
+ pass
+ else:
+ fcntl_flags |= fcntl.FD_CLOEXEC
+
fcntl.fcntl(in_pr, fcntl.F_SETFL,
- fcntl.fcntl(in_pr, fcntl.F_GETFL) | os.O_NONBLOCK)
+ fcntl.fcntl(in_pr, fcntl.F_GETFL) | fcntl_flags)
self._reg_id = self.scheduler.io_add_watch(in_pr,
self.scheduler.IO_IN, self._output_handler)
self._registered = True
-# Copyright 1999-2012 Gentoo Foundation
+# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from _emerge.SubProcess import SubProcess
files = self._files
master_fd, slave_fd = os.pipe()
+
+ fcntl_flags = os.O_NONBLOCK
+ try:
+ fcntl.FD_CLOEXEC
+ except AttributeError:
+ pass
+ else:
+ fcntl_flags |= fcntl.FD_CLOEXEC
+
fcntl.fcntl(master_fd, fcntl.F_SETFL,
- fcntl.fcntl(master_fd, fcntl.F_GETFL) | os.O_NONBLOCK)
+ fcntl.fcntl(master_fd, fcntl.F_GETFL) | fcntl_flags)
fd_pipes[self._metadata_fd] = slave_fd
-# Copyright 2010-2012 Gentoo Foundation
+# Copyright 2010-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+try:
+ import fcntl
+except ImportError:
+ # http://bugs.jython.org/issue1074
+ fcntl = None
+
from portage import os
from _emerge.AbstractPollTask import AbstractPollTask
from portage.cache.mappings import slot_dict_class
self._files.pipe_in = \
os.open(self.input_fifo, os.O_RDONLY|os.O_NONBLOCK)
+ if fcntl is not None:
+ try:
+ fcntl.FD_CLOEXEC
+ except AttributeError:
+ pass
+ else:
+ fcntl.fcntl(self._files.pipe_in, fcntl.F_SETFL,
+ fcntl.fcntl(self._files.pipe_in,
+ fcntl.F_GETFL) | fcntl.FD_CLOEXEC)
+
self._reg_id = self.scheduler.io_add_watch(
self._files.pipe_in,
self._registered_events, self._input_handler)
os.close(self._files.pipe_in)
self._files.pipe_in = \
os.open(self.input_fifo, os.O_RDONLY|os.O_NONBLOCK)
+
+ if fcntl is not None:
+ try:
+ fcntl.FD_CLOEXEC
+ except AttributeError:
+ pass
+ else:
+ fcntl.fcntl(self._files.pipe_in, fcntl.F_SETFL,
+ fcntl.fcntl(self._files.pipe_in,
+ fcntl.F_GETFL) | fcntl.FD_CLOEXEC)
+
self._reg_id = self.scheduler.io_add_watch(
self._files.pipe_in,
self._registered_events, self._input_handler)
-# Copyright 1999-2012 Gentoo Foundation
+# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from portage import os
else:
output_handler = self._output_handler
+ fcntl_flags = os.O_NONBLOCK
+ try:
+ fcntl.FD_CLOEXEC
+ except AttributeError:
+ pass
+ else:
+ fcntl_flags |= fcntl.FD_CLOEXEC
+
for f in self.input_files.values():
fcntl.fcntl(f.fileno(), fcntl.F_SETFL,
- fcntl.fcntl(f.fileno(), fcntl.F_GETFL) | os.O_NONBLOCK)
+ fcntl.fcntl(f.fileno(), fcntl.F_GETFL) | fcntl_flags)
self._reg_ids.add(self.scheduler.io_add_watch(f.fileno(),
self._registered_events, output_handler))
self._registered = True
"""
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
-# Copyright 2008-2012 Gentoo Foundation
+# Copyright 2008-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import fcntl
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)
-# Copyright 1999-2012 Gentoo Foundation
+# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import errno
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