MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _close_pipe_fds

Method _close_pipe_fds

tools/python-3.11.9-amd64/Lib/subprocess.py:1282–1309  ·  view source on GitHub ↗
(self,
                        p2cread, p2cwrite,
                        c2pread, c2pwrite,
                        errread, errwrite)

Source from the content-addressed store, hash-verified

1280 raise # resume the KeyboardInterrupt
1281
1282 def _close_pipe_fds(self,
1283 p2cread, p2cwrite,
1284 c2pread, c2pwrite,
1285 errread, errwrite):
1286 # self._devnull is not always defined.
1287 devnull_fd = getattr(self, '_devnull', None)
1288
1289 with contextlib.ExitStack() as stack:
1290 if _mswindows:
1291 if p2cread != -1:
1292 stack.callback(p2cread.Close)
1293 if c2pwrite != -1:
1294 stack.callback(c2pwrite.Close)
1295 if errwrite != -1:
1296 stack.callback(errwrite.Close)
1297 else:
1298 if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
1299 stack.callback(os.close, p2cread)
1300 if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
1301 stack.callback(os.close, c2pwrite)
1302 if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
1303 stack.callback(os.close, errwrite)
1304
1305 if devnull_fd is not None:
1306 stack.callback(os.close, devnull_fd)
1307
1308 # Prevent a double close of these handles/fds from __init__ on error.
1309 self._closed_child_pipe_fds = True
1310
1311 @contextlib.contextmanager
1312 def _on_error_fd_closer(self):

Callers 2

_execute_childMethod · 0.95
_posix_spawnMethod · 0.95

Calls 1

callbackMethod · 0.45

Tested by

no test coverage detected