diff --git a/process/process_posix.go b/process/process_posix.go index 92353b8..8853118 100644 --- a/process/process_posix.go +++ b/process/process_posix.go @@ -51,6 +51,8 @@ func getTerminalMap() (map[uint64]string, error) { return ret, nil } +// SendSignal sends a syscall.Signal to the process. +// Currently, SIGSTOP, SIGCONT, SIGTERM and SIGKILL are supported. func (p *Process) SendSignal(sig syscall.Signal) error { sigAsStr := "INT" switch sig { @@ -78,18 +80,27 @@ func (p *Process) SendSignal(sig syscall.Signal) error { return nil } +// Suspend sends SIGSTOP to the process. func (p *Process) Suspend() error { return p.SendSignal(syscall.SIGSTOP) } + +// Resume sends SIGCONT to the process. func (p *Process) Resume() error { return p.SendSignal(syscall.SIGCONT) } + +// Terminate sends SIGTERM to the process. func (p *Process) Terminate() error { return p.SendSignal(syscall.SIGTERM) } + +// Kill sends SIGKILL to the process. func (p *Process) Kill() error { return p.SendSignal(syscall.SIGKILL) } + +// Username returns a username of the process. func (p *Process) Username() (string, error) { uids, err := p.Uids() if err != nil {