Documentation
¶
Overview ¶
Package sys provides cross-platform process management utilities.
This package handles low-level OS-specific operations for process group management, signal handling, and process lifecycle control. It abstracts the differences between Unix (PGID-based) and Windows (taskkill-based) process termination strategies.
The primary purpose is to ensure proper cleanup of CLI processes and their children, preventing zombie processes and resource leaks.
Index ¶
- func AssignProcessToJob(jobHandle uintptr, process *os.Process) error
- func CloseJobHandle(jobHandle uintptr)
- func ExpandPath(path string) string
- func IsProcessAlive(process *os.Process) bool
- func KillProcessGroup(cmd *exec.Cmd, jobHandle uintptr)
- func SetupCmdSysProcAttr(cmd *exec.Cmd) (uintptr, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssignProcessToJob ¶ added in v0.9.3
AssignProcessToJob is a no-op on Unix (only used on Windows).
func CloseJobHandle ¶ added in v0.9.3
func CloseJobHandle(jobHandle uintptr)
CloseJobHandle is a no-op on Unix (only used on Windows).
func ExpandPath ¶ added in v0.21.0
ExpandPath expands the home directory tilde (~) in a path. If the path starts with "~/", it is replaced with the current user's home directory. If the path is exactly "~", it is replaced with the current user's home directory.
func IsProcessAlive ¶
IsProcessAlive checks if the process is still running using Signal(0) (Unix).
func KillProcessGroup ¶
KillProcessGroup terminates the entire process tree using the negative PID (Unix). The jobHandle parameter is ignored on Unix (only used on Windows).
Types ¶
This section is empty.