cmd

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2025 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSignaled

func IsSignaled(err error) bool

IsSignaled check if cmd exit signaled, err is Cmd.Wait() or Cmd.Run() result error.

func KillGroup added in v0.11.11

func KillGroup(cmd *exec.Cmd) error

func MustStop

func MustStop(ctx context.Context, cmd *exec.Cmd, singleSigWaitExitSec int, sig ...syscall.Signal) error

func MustStopGroup added in v0.11.11

func MustStopGroup(ctx context.Context, cmd *exec.Cmd, singleSigWaitExitSec int, sig ...syscall.Signal) error

func Stop

func Stop(cmd *exec.Cmd) error

func StopGroup added in v0.11.11

func StopGroup(cmd *exec.Cmd) error

Types

type Cfg

type Cfg struct {
	Env        map[string]string `json:"env"        yaml:"env"`
	RunAsUser  string            `json:"runAsUser"  yaml:"runAsUser"`
	WorkingDir string            `json:"workingDir" yaml:"workingDir"`
	Command    []string          `json:"command"    validate:"required" yaml:"command"`
	SetPgid    bool              `json:"setPgid"    yaml:"setPgid"`
}

func NewCfg added in v0.11.0

func NewCfg() *Cfg

type Result

type Result struct {
	Stdout        []string `json:"stdout"`
	Stderr        []string `json:"stderr"`
	ExitCode      int      `json:"exitCode"`
	Pid           int      `json:"pid"`
	StartTimeNano int64    `json:"startTimeNano"`
	StopTimeNano  int64    `json:"stopTimeNano"`
	Signaled      bool     `json:"signaled"`
	// contains filtered or unexported fields
}

func Run

func Run(command ...string) *Result

func RunCtx added in v0.9.13

func RunCtx(ctx context.Context, command ...string) *Result

func Start added in v0.8.2

func Start(ctx context.Context, cmd *exec.Cmd, cfg *Cfg, beforeStart ...func(cmd *exec.Cmd)) *Result

Start command you can get pid from Result.Pid, 0 means start fail.

func (*Result) Done added in v0.11.0

func (r *Result) Done() <-chan struct{}

func (*Result) Err added in v0.11.0

func (r *Result) Err() error

func (*Result) String added in v0.11.2

func (r *Result) String() string

Jump to

Keyboard shortcuts

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