process

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckProcess

func CheckProcess(processName string, insensitive bool) (bool, error)

func GetPidByName

func GetPidByName(name string) string

func KillProcess

func KillProcess(pid int) error

func KillProcessByName

func KillProcessByName(name string) error

func KillProcessByName2

func KillProcessByName2(name string)

func KillProcessImpl

func KillProcessImpl(process *os.Process) error

SIGINT与SIGTERM区别 1)SIGINT关联ctrl+c 2)SIGINT只能结束前台进程 3)通过ctrl+c对当前进程发送结束信号,信号被进程树接收到(即:不仅当前进程,子进程也会收到结束信号) SIGTERM与SIGKILL 1)SIGTERM可以被阻塞、处理和忽略;因此有的进程不能按预期的结束 2)kill不使用参数:发送SIGTERM信号,只有当前进程收到信号,若当前进程被kill,则子进程的父进程就会更改为init,即pid为1 3)kill命令的默认不带参数发生的信号就是SIGTERM,让程序友好的退出 ,当程序未退出时,可以使用kill -9强制退出

func ProcessInfo

func ProcessInfo(pid int32) (string, error)

Types

type Process

type Process struct {
	Pid int

	// PPid is the parent process ID for this process.
	PPid int

	// Executable name running this process. This is not a path to the
	// executable.
	Executable string

	// windows wmi process name
	Name string
}

func FindProcess

func FindProcess(processName string, insensitive bool) (*Process, error)

func GetProcesses

func GetProcesses(name string) []Process

func ListProcess

func ListProcess() ([]Process, error)

func ListProcess2

func ListProcess2() ([]Process, error)

Jump to

Keyboard shortcuts

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