-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[process][unix] err != nil
when calling process.Children() for a process without child processes
#1698
Comments
err != nil
when calling process.Children() for a process without child processes
To me this was introduced in #1231 (meant to handle places where 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 ( 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. |
…reliant on pgrep pgrep exits with an error 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. 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 shirou#1698
…reliant on pgrep 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. 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 shirou#1698
…reliant on pgrep 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 shirou#1698
…reliant on pgrep 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 deprecate 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 shirou#1698
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
// paste example code reproducing the bug you are reporting
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
]The text was updated successfully, but these errors were encountered: