Documentation
¶
Index ¶
- Variables
- func Command(name string, args ...string) *exec.Cmd
- func CommandContext(ctx context.Context, name string, args ...string) *exec.Cmd
- func Detach(cmd *exec.Cmd)
- func KillTreeOnCancel(cmd *exec.Cmd)
- func LockFile(path string) (*os.File, error)
- func StartedBy(ctx context.Context, pid, ancestor int) bool
- func Stop(ctx context.Context, pid int32, grace time.Duration) error
- func TerminateOnCancel(cmd *exec.Cmd, grace time.Duration)
Constants ¶
This section is empty.
Variables ¶
var ErrLocked = errors.New("locked by another process")
ErrLocked is LockFile's answer while another holder has the file locked.
Functions ¶
func Command ¶
Command is exec.Command for a child that must never open its own console window. On windows a console child of a parent without a console gets a fresh window, so infer running under a GUI host flashes one per spawn.
func CommandContext ¶
CommandContext is exec.CommandContext with the same console suppression as Command.
func Detach ¶ added in v0.239.0
Detach makes cmd's process outlive the caller's terminal: it starts in a session (a process group on windows) of its own, so closing the terminal or its Ctrl+C never reaches it.
func KillTreeOnCancel ¶ added in v0.233.2
KillTreeOnCancel kills the command and every process it started on timeout or cancel, on every platform, so a script's children die too and stop holding its output pipes open. A descendant whose parent already exited is reparented out of the tree and survives: job objects or cgroups if that ever shows up.
func LockFile ¶ added in v0.239.0
LockFile opens the file at path, creating it, and locks it for this process without waiting, or returns ErrLocked. Closing the file releases the lock, and so does the process exiting, however it exits, so a lock never outlives its holder.
func StartedBy ¶ added in v0.253.0
StartedBy reports whether ancestor is pid itself or a process up its parent chain. A process whose parent already exited was reparented and is not found.
func Stop ¶ added in v0.268.0
Stop asks process pid to exit, with SIGTERM where there are signals and a kill on windows, and kills it once grace passes with it still running. A process that is already gone counts as stopped.
func TerminateOnCancel ¶ added in v0.268.0
TerminateOnCancel makes a timeout or cancel ask cmd's process to exit, with SIGTERM where there are signals and a kill on windows, so it runs its own shutdown, and kills it once grace passes with it still running.
Types ¶
This section is empty.