|
|
@ -3,14 +3,11 @@
|
|
|
|
package common
|
|
|
|
package common
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"os/exec"
|
|
|
|
"os/exec"
|
|
|
|
"strconv"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var ErrorNoChildren = errors.New("Process does not have children or does not exist")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func CallLsof(invoke Invoker, pid int32, args ...string) ([]string, error) {
|
|
|
|
func CallLsof(invoke Invoker, pid int32, args ...string) ([]string, error) {
|
|
|
|
var cmd []string
|
|
|
|
var cmd []string
|
|
|
|
if pid == 0 { // will get from all processes.
|
|
|
|
if pid == 0 { // will get from all processes.
|
|
|
@ -51,7 +48,7 @@ func CallPgrep(invoke Invoker, pid int32) ([]int32, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
out, err := invoke.Command(pgrep, cmd...)
|
|
|
|
out, err := invoke.Command(pgrep, cmd...)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return []int32{}, ErrorNoChildren
|
|
|
|
return []int32{}, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lines := strings.Split(string(out), "\n")
|
|
|
|
lines := strings.Split(string(out), "\n")
|
|
|
|
ret := make([]int32, 0, len(lines))
|
|
|
|
ret := make([]int32, 0, len(lines))
|
|
|
|