shirou / gopsutil

psutil for golang
Other
10.66k stars 1.59k forks source link

[process][darwin][freebsd][linux][openbsd] Make process.Children not reliant on pgrep #1706

Closed Lomanic closed 2 months ago

Lomanic commented 2 months ago

pgrep -P $PID exits with status of 1 (and nothing in stdout nor stderr) both if a process doesn't exist or it doesn't have child processes, so we don't use it anymore on these OSes. We sort PIDs as pgrep did.

Also remove the ErrorNoChildren error when there are no child processes, this is erroneous (simply check for the length of the returned slice, plus this is not an error per se), this was only returned on linux anyway.

Fixes #1698

Lomanic commented 2 months ago

Tested only on linux and openbsd