fix: 添加后台执行设置以防止进程阻塞
This commit is contained in:
@@ -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).
|
||||
|
||||
@@ -270,7 +270,7 @@ func (r NeVersion) operateCommand(action, neType string, neFilePaths []string) (
|
||||
|
||||
// 2s后执行omc相关命令
|
||||
cmdStrArr = append(cmdStrArr, fmt.Sprintf("sudo rm -f /tmp/operate_run_%s_omc.out \n", action))
|
||||
cmdStrArr = append(cmdStrArr, fmt.Sprintf("nohup sh -c \"sleep 2s && %s\" > /tmp/operate_run_%s_omc.out2>&1 & \n", strings.Join(omcStrArr, " && "), action))
|
||||
cmdStrArr = append(cmdStrArr, fmt.Sprintf("nohup sh -c \"sleep 2s && %s\" > /tmp/operate_run_%s_omc.out >&1 & \n", strings.Join(omcStrArr, " && "), action))
|
||||
cmdStrArr = append(cmdStrArr, fmt.Sprintf("echo '%s' \n", okFlagStr))
|
||||
return okFlagStr, cmdStrArr, nil
|
||||
} else if neType == "IMS" {
|
||||
|
||||
Reference in New Issue
Block a user