The async context manager tries to SIGKILL the subprocess, which causes a PermissionError if that subprocess is sudo
import trio
async def main():
with trio.move_on_after(1):
await trio.run_process(['sleep', '2'])
print('Cancelled 1')
with trio.move_on_after(1):
await trio.run_process(['sudo', 'sleep', '2'])
print('Cancelled 2')
trio.run(main)