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

Method _execute_child

tools/python-3.11.9-amd64/Lib/subprocess.py:1436–1561  ·  view source on GitHub ↗

Execute program (MS Windows version)

(self, args, executable, preexec_fn, close_fds,
                           pass_fds, cwd, env,
                           startupinfo, creationflags, shell,
                           p2cread, p2cwrite,
                           c2pread, c2pwrite,
                           errread, errwrite,
                           unused_restore_signals,
                           unused_gid, unused_gids, unused_uid,
                           unused_umask,
                           unused_start_new_session, unused_process_group)

Source from the content-addressed store, hash-verified

1434
1435
1436 def _execute_child(self, args, executable, preexec_fn, close_fds,
1437 pass_fds, cwd, env,
1438 startupinfo, creationflags, shell,
1439 p2cread, p2cwrite,
1440 c2pread, c2pwrite,
1441 errread, errwrite,
1442 unused_restore_signals,
1443 unused_gid, unused_gids, unused_uid,
1444 unused_umask,
1445 unused_start_new_session, unused_process_group):
1446 """Execute program (MS Windows version)"""
1447
1448 assert not pass_fds, "pass_fds not supported on Windows."
1449
1450 if isinstance(args, str):
1451 pass
1452 elif isinstance(args, bytes):
1453 if shell:
1454 raise TypeError('bytes args is not allowed on Windows')
1455 args = list2cmdline([args])
1456 elif isinstance(args, os.PathLike):
1457 if shell:
1458 raise TypeError('path-like args is not allowed when '
1459 'shell is true')
1460 args = list2cmdline([args])
1461 else:
1462 args = list2cmdline(args)
1463
1464 if executable is not None:
1465 executable = os.fsdecode(executable)
1466
1467 # Process startup details
1468 if startupinfo is None:
1469 startupinfo = STARTUPINFO()
1470 else:
1471 # bpo-34044: Copy STARTUPINFO since it is modified above,
1472 # so the caller can reuse it multiple times.
1473 startupinfo = startupinfo.copy()
1474
1475 use_std_handles = -1 not in (p2cread, c2pwrite, errwrite)
1476 if use_std_handles:
1477 startupinfo.dwFlags |= _winapi.STARTF_USESTDHANDLES
1478 startupinfo.hStdInput = p2cread
1479 startupinfo.hStdOutput = c2pwrite
1480 startupinfo.hStdError = errwrite
1481
1482 attribute_list = startupinfo.lpAttributeList
1483 have_handle_list = bool(attribute_list and
1484 "handle_list" in attribute_list and
1485 attribute_list["handle_list"])
1486
1487 # If we were given an handle_list or need to create one
1488 if have_handle_list or (use_std_handles and close_fds):
1489 if attribute_list is None:
1490 attribute_list = startupinfo.lpAttributeList = {}
1491 handle_list = attribute_list["handle_list"] = \
1492 list(attribute_list.get("handle_list", []))
1493

Callers 1

__init__Method · 0.95

Calls 15

copyMethod · 0.95
_filter_handle_listMethod · 0.95
_close_pipe_fdsMethod · 0.95
_posix_spawnMethod · 0.95
_handle_exitstatusMethod · 0.95
list2cmdlineFunction · 0.85
STARTUPINFOClass · 0.85
listFunction · 0.85
tupleClass · 0.85
sortedFunction · 0.85
HandleClass · 0.70
setFunction · 0.50

Tested by

no test coverage detected