fix: 添加后台执行设置以防止进程阻塞

This commit is contained in:
TsMask
2025-05-29 17:23:36 +08:00
parent da5ef0725a
commit 20b865f1ab
2 changed files with 2 additions and 6 deletions

View File

@@ -4,7 +4,6 @@ import (
"fmt"
"os"
"os/exec"
"syscall"
"github.com/creack/pty"
)
@@ -13,10 +12,7 @@ import (
func NewClientSession(cols, rows int) (*LocalClientSession, error) {
// Create arbitrary command.
c := exec.Command("bash")
// 为防止当前进程阻塞,设置为后台执行
c.SysProcAttr = &syscall.SysProcAttr{
Setpgid: true, // 设置新进程组,确保安装进程与当前进程不在同一进程组
}
// Start the command with a pty.
ptmx, err := pty.StartWithSize(c, &pty.Winsize{
Rows: uint16(rows), // ws_row: Number of rows (in cells).