exec

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 5 Imported by: 13

README

exec CI GitHub release GoDoc

Usage

import (
    // "os/exec"
    "github.com/k1LoW/exec"
)

Difference between os/exec and k1LoW/exec

  • k1LoW/exec.Command returns *os/exec.Cmd with PGID set.
  • When context cancelled, k1LoW/exec.CommandContext send signal to process group.

References

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Command

func Command(name string, arg ...string) *exec.Cmd

Command returns *os/exec.Cmd with Setpgid = true.

func CommandContext

func CommandContext(ctx context.Context, name string, arg ...string) *exec.Cmd

CommandContext returns *os/exec.Cmd with Setpgid = true When ctx canceled, `github.com/k1LoW/exec.CommandContext` send signal to process group.

func KillCommand

func KillCommand(cmd *exec.Cmd) error

KillCommand send syscall.SIGKILL to cmd.Process.Pid process group KillCommand send taskkill to cmd.Process.Pid ( if runtime.GOOS == 'windows' ).

func LookPath

func LookPath(file string) (string, error)

LookPath is os/exec.LookPath.

func TerminateCommand

func TerminateCommand(cmd *exec.Cmd, sig os.Signal) error

TerminateCommand send signal to cmd.Process.Pid process group ( if runtime.GOOS != 'windows' ) TerminateCommand send taskkill to cmd.Process.Pid ( if runtime.GOOS == 'windows' ).

Types

type Exec

type Exec struct {
	Signal          os.Signal
	KillAfterCancel time.Duration // TODO
}

Exec represents an command executer.

func (*Exec) CommandContext

func (e *Exec) CommandContext(ctx context.Context, name string, arg ...string) *exec.Cmd

CommandContext returns *os/exec.Cmd with Setpgid = true When ctx canceled, `github.com/k1LoW/exec.CommandContext` send signal to process group.

type ExitError added in v0.4.0

type ExitError = exec.ExitError

Jump to

Keyboard shortcuts

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