EventLoop: enable FD_CLOEXEC on epoll fd
authorZac Medico <zmedico@gentoo.org>
Fri, 4 Jan 2013 03:39:19 +0000 (19:39 -0800)
committerZac Medico <zmedico@gentoo.org>
Fri, 4 Jan 2013 03:39:19 +0000 (19:39 -0800)
pym/portage/util/_eventloop/EventLoop.py

index d2d49636dc33a21f8ea4a26a6bb2fc36e46a11b0..6c2341bcd28dd943bd7f6b25cb02a0ce28d27464 100644 (file)
@@ -84,6 +84,17 @@ class EventLoop(object):
                                # IOError: [Errno 38] Function not implemented
                                pass
                        else:
+
+                               if fcntl is not None:
+                                       try:
+                                               fcntl.FD_CLOEXEC
+                                       except AttributeError:
+                                               pass
+                                       else:
+                                               fcntl.fcntl(epoll_obj.fileno(), fcntl.F_SETFL,
+                                                       fcntl.fcntl(epoll_obj.fileno(),
+                                                               fcntl.F_GETFL) | fcntl.FD_CLOEXEC)
+
                                self._poll_obj = _epoll_adapter(epoll_obj)
                                self.IO_ERR = select.EPOLLERR
                                self.IO_HUP = select.EPOLLHUP