fix(exec): terminate one-shot process trees on cleanup

Run one-shot commands in their own process tree and terminate all
descendants after timeout, cancellation, or unexpected failures.

Co-authored-by: TRAE CLI <noreply@bytedance.com>
This commit is contained in:
yorkhellen
2026-08-12 14:37:27 +08:00
committed by chengyongru
co-authored by TRAE CLI
parent abfcdd481a
commit d64b84604c
3 changed files with 65 additions and 20 deletions
+18 -6
View File
@@ -302,7 +302,9 @@ class TestPathAppendPlatform:
captured_cmd = None
captured_env = {}
async def capture_spawn(cmd, cwd, env, shell_program=None, login=True):
async def capture_spawn(
cmd, cwd, env, shell_program=None, login=True, *, process_tree=False,
):
nonlocal captured_cmd
captured_cmd = cmd
captured_env.update(env)
@@ -331,7 +333,9 @@ class TestPathAppendPlatform:
captured_cmd = None
captured_env = {}
async def capture_spawn(cmd, cwd, env, shell_program=None, login=True, *, stdin=None):
async def capture_spawn(
cmd, cwd, env, shell_program=None, login=True, *, stdin=None, process_tree=False,
):
nonlocal captured_cmd
captured_cmd = cmd
captured_env.update(env)
@@ -359,7 +363,9 @@ class TestPathAppendPlatform:
captured_cmd = None
captured_env = {}
async def capture_spawn(cmd, cwd, env, shell_program=None, login=True, *, stdin=None):
async def capture_spawn(
cmd, cwd, env, shell_program=None, login=True, *, stdin=None, process_tree=False,
):
nonlocal captured_cmd
captured_cmd = cmd
captured_env.update(env)
@@ -389,7 +395,9 @@ class TestPathAppendPlatform:
captured_env = {}
async def capture_spawn(cmd, cwd, env, shell_program=None, login=True):
async def capture_spawn(
cmd, cwd, env, shell_program=None, login=True, *, process_tree=False,
):
captured_env.update(env)
return mock_proc
@@ -412,7 +420,9 @@ class TestPathAppendPlatform:
captured_env = {}
async def capture_spawn(cmd, cwd, env, shell_program=None, login=True, *, stdin=None):
async def capture_spawn(
cmd, cwd, env, shell_program=None, login=True, *, stdin=None, process_tree=False,
):
captured_env.update(env)
return mock_proc
@@ -558,7 +568,9 @@ class TestExecuteEndToEnd:
mock_proc.returncode = 0
captured_login = []
async def capture_spawn(cmd, cwd, env, shell_program=None, login=None, *, stdin=None):
async def capture_spawn(
cmd, cwd, env, shell_program=None, login=None, *, stdin=None, process_tree=False,
):
captured_login.append(login)
return mock_proc