Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Add function to get process state on Unix. #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions process.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ type Process interface {
// Executable name running this process. This is not a path to the
// executable.
Executable() string

// State for this process. Returns zero on Darwin and Windows.
State() rune
}

// Processes returns all processes.
Expand Down
4 changes: 4 additions & 0 deletions process_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ func (p *DarwinProcess) Executable() string {
return p.binary
}

func (p *DarwinProcess) State() rune {
return 0
}

func findProcess(pid int) (Process, error) {
ps, err := processes()
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions process_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ func (p *UnixProcess) PPid() int {
return p.ppid
}

func (p *UnixProcess) State() rune {
return p.state
}

func (p *UnixProcess) Executable() string {
return p.binary
}
Expand Down
4 changes: 4 additions & 0 deletions process_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func (p *UnixProcess) PPid() int {
return p.ppid
}

func (p *UnixProcess) State() rune {
return p.state
}

func (p *UnixProcess) Executable() string {
return p.binary
}
Expand Down
4 changes: 4 additions & 0 deletions process_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func (p *WindowsProcess) Executable() string {
return p.exe
}

func (p *WindowsProcess) State() rune {
return 0
}

func newWindowsProcess(e *PROCESSENTRY32) *WindowsProcess {
// Find when the string ends for decoding
end := 0
Expand Down