cmd

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForceKillProcess

func ForceKillProcess(ctx *gin.Context, runCmd *exec.Cmd, isWait bool) (err error)

func GraceKillProcess

func GraceKillProcess(ctx *gin.Context, runCmd *exec.Cmd, isWait bool) (err error)

func RunCmdWithExitSignal

func RunCmdWithExitSignal(ctx *gin.Context, cmdContext CmdContext, forceExitChan ExitChan) (err error)

func RunCmdWithTimeout

func RunCmdWithTimeout(ctx *gin.Context, cmdContext CmdContext) (err error)

func StopProcess

func StopProcess(ctx *gin.Context, runCmd *exec.Cmd, timeout int64) (err error)

退出子进程

func StopProcessNonBlocking

func StopProcessNonBlocking(ctx *gin.Context, runCmd *exec.Cmd, timeout int64) (killCancel *time.Timer, err error)

发送信号,但不对 cmd 执行Wait()。 注:每个进程必须Wait,否则会出现僵尸进程(zombie process) 返回的timer可以用于取消ForceKillProcess()

func TraceOneProcess

func TraceOneProcess(ctx *gin.Context, pid int, path string) (err error)

sudo strace -o output.log -p 66887 todo 会存在大量资源消耗 ps -C gst-launch-1.0 -mww -o pid,ppid,pgid,cpu,lwp,stime,time,stat,wchan,cmd

Types

type CmdContext

type CmdContext struct {
	Stdout         *os.File `json:"stdout"`           //进程执行的输出参数
	MaxExecuteTime int64    `json:"max_execute_time"` //进程最多执行时间
	WaitTimeOut    int64    `json:"wait_time_out"`    //进程执行超时后,暴力杀死进程前的等待时间
	BinPath        string   `json:"bin_path"`         //可执行文件路径
	Args           []string `json:"args"`             //可执行文件参数
	BinEnv         []string `json:"bin_env"`          //可执行文件需要的环境变量
}

type ExitChan

type ExitChan chan bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL