Skip to content

Commit

Permalink
test OSError in waitid
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Dec 19, 2024
1 parent 8858398 commit e5fa8cd
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/trio/_tests/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,31 @@ async def test_wait_reapable_fails(background_process: BackgroundProcessType) ->
signal.signal(signal.SIGCHLD, old_sigchld)


@pytest.mark.skipif(not posix, reason="POSIX specific")
@background_process_param
async def test_wait_reapable_fails_no_pidfd(
background_process: BackgroundProcessType,
) -> None:
if TYPE_CHECKING and sys.platform == "win32":
return
with mock.patch("trio._subprocess.can_try_pidfd_open", new=False):
old_sigchld = signal.signal(signal.SIGCHLD, signal.SIG_IGN)
try:
# With SIGCHLD disabled, the wait() syscall will wait for the
# process to exit but then fail with ECHILD. Make sure we
# support this case as the stdlib subprocess module does.
async with background_process(SLEEP(3600)) as proc:
async with _core.open_nursery() as nursery:
nursery.start_soon(proc.wait)
await wait_all_tasks_blocked()
proc.kill()
nursery.cancel_scope.deadline = _core.current_time() + 1.0
assert not nursery.cancel_scope.cancelled_caught
assert proc.returncode == 0 # exit status unknowable, so...
finally:
signal.signal(signal.SIGCHLD, old_sigchld)


@slow
def test_waitid_eintr() -> None:
# This only matters on PyPy (where we're coding EINTR handling
Expand Down

0 comments on commit e5fa8cd

Please sign in to comment.