diff --git a/process_dragonfly.go b/process_dragonfly.go new file mode 100644 index 0000000..bac8f57 --- /dev/null +++ b/process_dragonfly.go @@ -0,0 +1,29 @@ +// +build dragonfly + +package ps + +import ( + "fmt" + "io/ioutil" +) + +// Refresh reloads all the data associated with this process. +func (p *UnixProcess) Refresh() error { + statPath := fmt.Sprintf("/proc/%d/status", p.pid) + dataBytes, err := ioutil.ReadFile(statPath) + if err != nil { + return err + } + + data := string(dataBytes) + + _, err = fmt.Sscanf(data, + "%s %d %d %d %d", + &p.binary, + &p.pid, + &p.ppid, + &p.pgrp, + &p.sid) + + return err +} diff --git a/process_unix.go b/process_unix.go index 3b733ce..598fdc2 100644 --- a/process_unix.go +++ b/process_unix.go @@ -1,4 +1,4 @@ -// +build linux solaris +// +build linux solaris dragonfly package ps diff --git a/process_unix_test.go b/process_unix_test.go index 754073e..11e3233 100644 --- a/process_unix_test.go +++ b/process_unix_test.go @@ -1,4 +1,4 @@ -// +build linux solaris +// +build linux solaris dragonfly package ps