fix: prevent agent hang when backgrounding processes via terminal tool
bash -lic with a PTY enables job control (set -m), which waits for all background jobs before the shell exits. A command like `python3 -m http.server &>/dev/null &` hangs forever because the shell never completes. Prefix `set +m;` to disable job control while keeping -i for .bashrc sourcing and PTY for interactive tools. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -334,7 +334,7 @@ class ProcessRegistry:
|
|||||||
pty_env = _sanitize_subprocess_env(os.environ, env_vars)
|
pty_env = _sanitize_subprocess_env(os.environ, env_vars)
|
||||||
pty_env["PYTHONUNBUFFERED"] = "1"
|
pty_env["PYTHONUNBUFFERED"] = "1"
|
||||||
pty_proc = _PtyProcessCls.spawn(
|
pty_proc = _PtyProcessCls.spawn(
|
||||||
[user_shell, "-lic", command],
|
[user_shell, "-lic", f"set +m; {command}"],
|
||||||
cwd=session.cwd,
|
cwd=session.cwd,
|
||||||
env=pty_env,
|
env=pty_env,
|
||||||
dimensions=(30, 120),
|
dimensions=(30, 120),
|
||||||
@@ -375,7 +375,7 @@ class ProcessRegistry:
|
|||||||
bg_env = _sanitize_subprocess_env(os.environ, env_vars)
|
bg_env = _sanitize_subprocess_env(os.environ, env_vars)
|
||||||
bg_env["PYTHONUNBUFFERED"] = "1"
|
bg_env["PYTHONUNBUFFERED"] = "1"
|
||||||
proc = subprocess.Popen(
|
proc = subprocess.Popen(
|
||||||
[user_shell, "-lic", command],
|
[user_shell, "-lic", f"set +m; {command}"],
|
||||||
text=True,
|
text=True,
|
||||||
cwd=session.cwd,
|
cwd=session.cwd,
|
||||||
env=bg_env,
|
env=bg_env,
|
||||||
|
|||||||
Reference in New Issue
Block a user