|
|
|
@ -4,6 +4,7 @@ package process
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
|
"io/ioutil"
|
|
|
|
|
"os"
|
|
|
|
@ -18,6 +19,8 @@ import (
|
|
|
|
|
"github.com/shirou/gopsutil/net"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var ErrorNoChildren = errors.New("Process does not have children or does not exist")
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
PrioProcess = 0 // linux/resource.h
|
|
|
|
|
)
|
|
|
|
@ -205,6 +208,9 @@ func (p *Process) MemoryPercent() (float32, error) {
|
|
|
|
|
func (p *Process) Children() ([]*Process, error) {
|
|
|
|
|
pids, err := common.CallPgrep(invoke, p.Pid)
|
|
|
|
|
if err != nil {
|
|
|
|
|
if err == common.ErrorNoChildren {
|
|
|
|
|
return nil, ErrorNoChildren
|
|
|
|
|
}
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
ret := make([]*Process, 0, len(pids))
|
|
|
|
|