py3: remove dead code to make file descriptors non-inheritable
authorManuel Jacob <me@manueljacob.de>
Sun, 29 May 2022 15:43:21 +0200
changeset 49296 b6b6ae9ea91e
parent 49295 7d9a45c7517f
child 49297 402f9f0f9387
py3: remove dead code to make file descriptors non-inheritable On Python 3, file descriptors are already non-inheritable by default.
tests/test-stdio.py
--- a/tests/test-stdio.py	Sun May 29 15:53:01 2022 +0200
+++ b/tests/test-stdio.py	Sun May 29 15:43:21 2022 +0200
@@ -16,25 +16,6 @@
 from mercurial import pycompat, util
 
 
-if pycompat.ispy3:
-
-    def set_noninheritable(fd):
-        # On Python 3, file descriptors are non-inheritable by default.
-        pass
-
-
-else:
-    if pycompat.iswindows:
-        # unused
-        set_noninheritable = None
-    else:
-        import fcntl
-
-        def set_noninheritable(fd):
-            old = fcntl.fcntl(fd, fcntl.F_GETFD)
-            fcntl.fcntl(fd, fcntl.F_SETFD, old | fcntl.FD_CLOEXEC)
-
-
 TEST_BUFFERING_CHILD_SCRIPT = r'''
 import os
 
@@ -127,10 +108,6 @@
 @contextlib.contextmanager
 def _pipes():
     rwpair = os.pipe()
-    # Pipes are already non-inheritable on Windows.
-    if not pycompat.iswindows:
-        set_noninheritable(rwpair[0])
-        set_noninheritable(rwpair[1])
     with _closing(rwpair):
         yield rwpair
 
@@ -143,8 +120,6 @@
     import tty
 
     rwpair = pty.openpty()
-    set_noninheritable(rwpair[0])
-    set_noninheritable(rwpair[1])
     with _closing(rwpair):
         tty.setraw(rwpair[0])
         yield rwpair