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

This commit is contained in:
TsMask
2025-05-29 17:11:35 +08:00
parent 8037a0ce5a
commit 5c085bc60c

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"os/exec"
"syscall"
"github.com/creack/pty"
)
@@ -12,7 +13,12 @@ import (
func NewClientSession(cols, rows int) (*LocalClientSession, error) {
// Create arbitrary command.
c := exec.Command("bash")
// 为防止当前进程阻塞,设置为后台执行
c.SysProcAttr = &syscall.SysProcAttr{
HideWindow: true, // 隐藏窗口
CreationFlags: syscall.CREATE_NEW_CONSOLE, // 创建新控制台
NoInheritHandles: true, // 不继承句柄
}
// Start the command with a pty.
ptmx, err := pty.StartWithSize(c, &pty.Winsize{
Rows: uint16(rows), // ws_row: Number of rows (in cells).