[pypy-commit] pypy py3.5-noninherit: select.kqueue(), can't test but simple enough

arigo pypy.commits at gmail.com
Fri Aug 26 10:32:08 EDT 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5-noninherit
Changeset: r86567:462212502307
Date: 2016-08-26 16:29 +0200
http://bitbucket.org/pypy/pypy/changeset/462212502307/

Log:	select.kqueue(), can't test but simple enough

diff --git a/pypy/module/select/interp_kqueue.py b/pypy/module/select/interp_kqueue.py
--- a/pypy/module/select/interp_kqueue.py
+++ b/pypy/module/select/interp_kqueue.py
@@ -1,10 +1,11 @@
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.error import oefmt
-from pypy.interpreter.error import exception_from_saved_errno
+from pypy.interpreter.error import exception_from_saved_errno, wrap_oserror
 from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.typedef import TypeDef, generic_new_descr, GetSetProperty
 from rpython.rlib._rsocket_rffi import socketclose_no_errno
 from rpython.rlib.rarithmetic import r_uint
+from rpython.rlib import rposix
 from rpython.rtyper.lltypesystem import rffi, lltype
 from rpython.rtyper.tool import rffi_platform
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
@@ -115,6 +116,10 @@
         kqfd = syscall_kqueue()
         if kqfd < 0:
             raise exception_from_saved_errno(space, space.w_IOError)
+        try:
+            rposix.set_inheritable(kqfd, False)
+        except OSError as e:
+            raise wrap_oserror(space, e)
         return space.wrap(W_Kqueue(space, kqfd))
 
     @unwrap_spec(fd=int)
diff --git a/pypy/module/select/test/test_kqueue.py b/pypy/module/select/test/test_kqueue.py
--- a/pypy/module/select/test/test_kqueue.py
+++ b/pypy/module/select/test/test_kqueue.py
@@ -186,3 +186,10 @@
         a.close()
         b.close()
         kq.close()
+
+    def test_non_inheritable(self):
+        import select, posix
+
+        kq = select.kqueue()
+        assert posix.get_inheritable(kq.fileno()) == False
+        kq.close()


More information about the pypy-commit mailing list