This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This implements the UnixProcess' Refresh method for solaris.
- Loading branch information
Showing
3 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build linux | ||
// +build linux solaris | ||
|
||
package ps | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build linux | ||
// +build linux solaris | ||
|
||
package ps | ||
|
||
|