def test_dup_dup2_non_inheritable(): for preset in [False, True]: fd1, fd2 = os.pipe() rposix.set_inheritable(fd1, preset) rposix.set_inheritable(fd2, preset) fd3 = rposix.dup(fd1, True) assert rposix.get_inheritable(fd3) == True fd4 = rposix.dup(fd1, False) assert rposix.get_inheritable(fd4) == False rposix.dup2(fd2, fd4, False) assert rposix.get_inheritable(fd4) == False rposix.dup2(fd2, fd3, True) assert rposix.get_inheritable(fd3) == True os.close(fd1) os.close(fd2) os.close(fd3) os.close(fd4)
def test_dup_dup2_non_inheritable(): for preset in [False, True]: fd1, fd2 = os.pipe() rposix.set_inheritable(fd1, preset) rposix.set_inheritable(fd2, preset) fd3 = rposix.dup(fd1, True) assert rposix.get_inheritable(fd3) == True fd4 = rposix.dup(fd1, False) assert rposix.get_inheritable(fd4) == False rposix.dup2(fd2, fd4, False) assert rposix.get_inheritable(fd4) == False rposix.dup2(fd2, fd3, True) assert rposix.get_inheritable(fd3) == True os.close(fd1) os.close(fd2) os.close(fd3) os.close(fd4)