(self)
| 3178 | self.assertIn('overriding close_fds', str(context.warning)) |
| 3179 | |
| 3180 | def test_pass_fds_inheritable(self): |
| 3181 | script = support.findfile("fd_status.py", subdir="subprocessdata") |
| 3182 | |
| 3183 | inheritable, non_inheritable = os.pipe() |
| 3184 | self.addCleanup(os.close, inheritable) |
| 3185 | self.addCleanup(os.close, non_inheritable) |
| 3186 | os.set_inheritable(inheritable, True) |
| 3187 | os.set_inheritable(non_inheritable, False) |
| 3188 | pass_fds = (inheritable, non_inheritable) |
| 3189 | args = [sys.executable, script] |
| 3190 | args += list(map(str, pass_fds)) |
| 3191 | |
| 3192 | p = subprocess.Popen(args, |
| 3193 | stdout=subprocess.PIPE, close_fds=True, |
| 3194 | pass_fds=pass_fds) |
| 3195 | output, ignored = p.communicate() |
| 3196 | fds = set(map(int, output.split(b','))) |
| 3197 | |
| 3198 | # the inheritable file descriptor must be inherited, so its inheritable |
| 3199 | # flag must be set in the child process after fork() and before exec() |
| 3200 | self.assertEqual(fds, set(pass_fds), "output=%a" % output) |
| 3201 | |
| 3202 | # inheritable flag must not be changed in the parent process |
| 3203 | self.assertEqual(os.get_inheritable(inheritable), True) |
| 3204 | self.assertEqual(os.get_inheritable(non_inheritable), False) |
| 3205 | |
| 3206 | |
| 3207 | # bpo-32270: Ensure that descriptors specified in pass_fds |
nothing calls this directly
no test coverage detected