diff --git a/src/framework/cmd/cmd_session.go b/src/framework/cmd/cmd_session.go index dfeb146c..40d9ee65 100644 --- a/src/framework/cmd/cmd_session.go +++ b/src/framework/cmd/cmd_session.go @@ -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).