Message389832
spawn_main() could handle a PermissionError by checking the exit code. If the parent has terminated already, then simply exit quietly. _winapi.PROCESS_QUERY_LIMITED_INFORMATION would need to be defined. For example:
def spawn_main(pipe_handle, parent_pid=None, tracker_fd=None):
"""Run code specified by data received over a pipe."""
assert is_forking(sys.argv), "Not forking"
if sys.platform == 'win32':
import msvcrt
import _winapi
if parent_pid is not None:
source_process = _winapi.OpenProcess(
_winapi.SYNCHRONIZE |
_winapi.PROCESS_DUP_HANDLE |
_winapi.PROCESS_QUERY_LIMITED_INFORMATION,
False, parent_pid)
else:
source_process = None
try:
new_handle = reduction.duplicate(
pipe_handle, source_process=source_process)
fd = msvcrt.open_osfhandle(new_handle, os.O_RDONLY)
exitcode = _main(fd, source_process)
except PermissionError:
if (source_process is None or
_winapi.GetExitCodeProcess(source_process) ==
_winapi.STILL_ACTIVE):
raise
exitcode = 1
else:
from . import resource_tracker
resource_tracker._resource_tracker._fd = tracker_fd
exitcode = _main(pipe_handle, os.dup(pipe_handle))
sys.exit(exitcode) |
|
Date |
User |
Action |
Args |
2021-03-30 15:36:07 | eryksun | set | recipients:
+ eryksun, pitrou, vstinner, s0undt3ch, pablogsal, pemryan |
2021-03-30 15:36:07 | eryksun | set | messageid: <1617118567.77.0.665186783881.issue38263@roundup.psfhosted.org> |
2021-03-30 15:36:07 | eryksun | link | issue38263 messages |
2021-03-30 15:36:07 | eryksun | create | |
|