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

Commit

Permalink
Add solaris support
Browse files Browse the repository at this point in the history
This implements the UnixProcess' Refresh method for solaris.
  • Loading branch information
gfrey committed Feb 11, 2017
1 parent 912cb9b commit 9c7b42d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
34 changes: 34 additions & 0 deletions process_solaris.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// +build solaris

package ps

// #include <fcntl.h>
// #include <procfs.h>
//
// int read_psinfo(const char *path, psinfo_t *psi) {
// int fh;
// int retval = 0;
// if ((fh = open(path, O_RDONLY)) >= 0) {
// if (read(fh, psi, sizeof(psinfo_t)) == -1) {
// retval = 1;
// }
// close(fh);
// return retval;
// }
// return 2;
// }
import "C"

import "fmt"

func (p *UnixProcess) Refresh() error {
var psinfo C.psinfo_t
path := fmt.Sprintf("/proc/%d/psinfo", p.pid)
_, err := C.read_psinfo(C.CString(path), &psinfo)
if err != nil {
return err
}
p.ppid = int(psinfo.pr_ppid)
p.binary = C.GoString(&psinfo.pr_fname[0])
return nil
}
2 changes: 1 addition & 1 deletion process_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build linux
// +build linux solaris

package ps

Expand Down
2 changes: 1 addition & 1 deletion process_unix_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build linux
// +build linux solaris

package ps

Expand Down

0 comments on commit 9c7b42d

Please sign in to comment.