2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 07:57:21 +08:00

fix: 解决连接中断后命令不被杀死的问题

This commit is contained in:
2026-01-12 04:16:53 +08:00
parent ddfcd3e45c
commit c3054dcb91
2 changed files with 6 additions and 32 deletions

View File

@@ -69,22 +69,9 @@ func (t *Turn) Wait() {
// Close 关闭 PTY 并终止子进程
func (t *Turn) Close() {
_ = t.cmd.Process.Signal(syscall.SIGTERM)
// 等待最多 10 秒
done := make(chan struct{})
go func() {
_ = t.cmd.Wait()
close(done)
}()
select {
case <-done:
// 进程已退出
case <-time.After(10 * time.Second):
// 超时KILL
_ = t.cmd.Process.Kill()
}
// 等待 10 秒
time.Sleep(10 * time.Second)
_ = t.cmd.Process.Kill()
_ = t.ptmx.Close()
}