cmdKit

package
v2.8.135 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(name string, args ...string) ([]byte, error)

Execute 执行命令(会阻塞直到命令结束)

!!!: (1) exec.Cmd结构体执行时,会处理路径中的空格(e.g. java可执行文件的绝对路径、-Djava.ext.dirs=的路径...) (2) 假如自行处理命令行中的路径,反而会导致: 命令执行失败

func ExecuteToString

func ExecuteToString(name string, args ...string) (string, error)

ExecuteToString 执行命令(会阻塞直到命令结束)

func NewCommand

func NewCommand(name string, args []string, options ...CmdOption) *exec.Cmd

NewCommand

@param args 可以为nil

Types

type CmdOption added in v2.8.135

type CmdOption func(opts *CmdOptions)

func WithPdeathsig added in v2.8.135

func WithPdeathsig(pdeathsig syscall.Signal) CmdOption

WithPdeathsig

适用环境: Linux

func WithSetpgid added in v2.8.135

func WithSetpgid(setpgid bool) CmdOption

WithSetpgid

适用环境: Linux、macOS

type CmdOptions added in v2.8.135

type CmdOptions struct {
	// Setpgid sets the process group ID of the child to Pgid,
	// or, if Pgid == 0, to the new child's process ID.
	Setpgid bool

	// Pdeathsig, if non-zero, is a signal that the kernel will send to
	// the child process when the creating thread dies. Note that the signal
	// is sent on thread termination, which may happen before process termination.
	// There are more details at https://go.dev/issue/27505.
	Pdeathsig syscall.Signal
}

CmdOptions 参考: exec_linux.go

func (CmdOptions) NewCommand added in v2.8.135

func (opts CmdOptions) NewCommand(name string, args ...string) *exec.Cmd

Jump to

Keyboard shortcuts

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