Closed lichunqiang closed 4 days ago
To me this was introduced in #1231 (meant to handle places where pgrep
is missing).
As pgrep returns 1 (without any message in stderr/out) both when there's no child process found or the parent process doesn't exist (pgrep -P $$; echo $?
vs pgrep -P 3; echo $?
), gopsutil should get rid of pgrep and follow psutil, like this on linux (calls ppid() on all processes on all other posix OSes).
As an aside, I think this ErrorNoChildren error should not exist in the first place, the Children() function should simply return a nil error and an empty slice as this is not an error.
Describe the bug Calling
Children()
on a process without child processes returns a non-nil errthe source code uses
common.CallPgrepWithContext
which callspgrep -P $PID
. If input pid is without child processes,pgrep
exit code is1
, the function call returns error withexits status 1
To Reproduce
Expected behavior The function should return ErrorNoChildren?
Environment (please complete the following information):
ver
]/etc/os-release
and the result ofuname -a
]sw_vers
anduname -a
freebsd-version -k -r -u
anduname -a
]uname -a
]Additional context [Cross-compiling? Paste the command you are using to cross-compile and the result of the corresponding
go env
]