fix: Chrome 进程使用独立 session 避免被父进程组回收#60
Open
yskhhh wants to merge 1 commit intoautoclaw-cc:mainfrom
Open
Conversation
使用 start_new_session=True 启动 Chrome,使其成为独立进程组的领导者。 在 openclaw、Claude Code 等 Agent 平台中,命令执行完毕后平台会 清理整个进程组,导致 Chrome 子进程随之退出。 加入此参数后 Chrome 与 Python 父进程解耦,可在后台持续运行, 支持跨命令复用同一 Chrome 实例。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
在 openclaw、Claude Code 等 Agent 平台中执行 skill 命令时,
平台在命令结束后会清理整个进程组(SIGTERM/SIGKILL),
导致通过 subprocess.Popen 启动的 Chrome 子进程随之退出。
表现为:每次调用 CLI 命令后 Chrome 自动关闭,
下一条命令不得不重新冷启动 Chrome,增加延迟且体验差。
修复
在
launch_chrome()的subprocess.Popen中加入start_new_session=True。这会让 Chrome 成为新进程组的领导者,与 Python 父进程完全解耦。
父进程(或其所在进程组)被终止时,Chrome 不受影响,可持续在后台运行,
实现跨命令复用同一 Chrome 实例。
影响范围
仅影响
launch_chrome()的启动行为,对 CDP 连接、端口复用逻辑无任何改动。