[Bug] Linux 上关闭集成 bash 终端后,后台任务偶尔没有收到挂断而残留
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 43/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- bash, linux
- Lĩnh vực
- operating-systems
Hướng nghiên cứu
Start with TestClosingAnIntegratedShellHangsUpTheShellAndItsJobs and TestClosingAnIntegratedShellRightAfterACommandHangsUpItsJobs in integration_unix_test.go, then inspect shell.go's hangUp path. Reproduce on the specified Ubuntu runner and use logs or strace to establish whether closing the pty makes bash exit through EOF before it handles SIGHUP. Done means the background job exits within five seconds after Shell.Close in both tests.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Platform / 平台
Other / 其他
Area / 模块
Terminal / 终端
Lithe version / Lithe 版本
main f6f1dc12e(Desktop CI 运行在 11eb12f9e #2010 之后的 main 提交上)
Priority / 优先级
P2 / 后续考虑:目前不着急,可安排到后续版本
OS and architecture / 操作系统与架构
GitHub Actions ubuntu-26.04 runner(Ubuntu 26.04.1 LTS,x86_64,镜像版本 20261111.82.6)
Environment / 环境信息
bash:Ubuntu 26.04 自带的 bash(/bin/bash 与 PATH 中的 bash)。
系统 profile:带有 systemd 257 起提供的 /etc/profile.d/80-systemd-osc-context.sh,它把 PROMPT_COMMAND 改成数组,并在 PS0 前加命令替换。
macOS 本机:Homebrew bash 5.3.9 和 /bin/bash 3.2.57,均无法复现。
Steps to reproduce / 复现步骤
偶发问题,只在 Linux CI 上出现:
- 在 ubuntu-26.04 runner 上运行
scripts/desktop/desktop-go.sh test ./internal/localshell(Desktop CI 的 “Vet and test on Linux”)。 TestClosingAnIntegratedShellHangsUpTheShellAndItsJobs/bash:通过 Shell 集成启动 bash,回到提示符后执行sleep 300 & echo job=$!,等到下一个提示符再关闭终端(Shell.Close)。TestClosingAnIntegratedShellRightAfterACommandHangsUpItsJobs//bin/bash:同样的命令,看到job=输出就关闭,这时还没出现下一个提示符。
频率:在 main 最近 22 次 Desktop CI 里出现 3 次:
- run 43800467067、43839612949:第 1 个测试的
bash子用例; - run 43874488514:第 2 个测试的
/bin/bash子用例。
Expected behavior / 预期行为
关闭终端后,bash 收到挂断信号,并把它转给后台任务,sleep 在 5 秒内结束。设计见 .agents/notes/implemented/architecture/2026-11-16-local-shell-integration-shim.md。
Actual behavior / 实际行为
偶尔出现:Shell 已经结束,后台任务却还活着,测试报 the shell's job <pid> outlived the closed terminal by 5s。在真实使用中,这意味着关闭终端标签页后,后台任务有时会残留。
Logs or diagnostic output / 日志或诊断输出
--- FAIL: TestClosingAnIntegratedShellHangsUpTheShellAndItsJobs (5.23s)
--- FAIL: TestClosingAnIntegratedShellHangsUpTheShellAndItsJobs/bash (5.15s)
integration_unix_test.go:266: the shell's job 7270 outlived the closed terminal by 5s
--- FAIL: TestClosingAnIntegratedShellRightAfterACommandHangsUpItsJobs (5.74s)
--- FAIL: TestClosingAnIntegratedShellRightAfterACommandHangsUpItsJobs//bin/bash (5.04s)
integration_unix_test.go:282: the shell's job 14960 outlived the closed terminal by 5s
在 macOS 上做了对照:
- 用 bash 5.3 把这两个测试各跑 30 次,都没有失败。
- 在测试 home 里放入一份 systemd 的 profile 副本(
/proc路径换成/dev/null)后,再跑 30 次,也没有失败。
待确认的推测,未经验证:shell.go 的 hangUp 先发出 SIGHUP,紧接着关闭 pty master。在 Linux 上,bash 有可能先从 readline 读到 EOF/EIO,然后按读到 EOF 的方式退出。这条退出路径不会执行 hangup_all_jobs,任务就留了下来。要在 Linux 上验证这一点,需要加日志或用 strace 观察退出路径。
Screenshots or recordings / 截图或录屏
不适用(CI 测试失败,没有界面)
Checklist / 提交前检查
- I searched existing issues for duplicates. / 我已搜索现有 Issue,确认没有重复报告。
- I removed secrets and personal data from the report. / 我已从报告中移除敏感信息和个人数据。
- Ngôn ngữ chính
- TypeScript
- Star
- 1.8k
- Fork
- 151
- Merge trung bình
- 3 giờ 48 phút
- Pull request đã merge (30 ngày)
- 571
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của 1lck/Lithe-IDEA
-
review: medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
1lck/Lithe-IDEA#2432 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
review: medium
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
1lck/Lithe-IDEA#2431 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
refactor review: high
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
1lck/Lithe-IDEA#2376 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:ui enhancement P2 platform:cross-platform refactor review: high
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
1lck/Lithe-IDEA#2365 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
review: medium
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 57/100
1lck/Lithe-IDEA#2434 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của 1lck/Lithe-IDEA
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
posit-dev/positron-sas-extension#196 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug composer
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
inmanta/web-console#8037 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: AlFajer Palestine FHDĐang mởcheck:passed streams:add
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug: v5 dist/types/components.d.ts imports @stencil/core/runtime instead of ./stencil-public-runtimeĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày