Check if a process is running using it's name #5768
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Required for all PRs:
This PR relates to #5746. When you provide a
pid_file
that exists, has a (int32) number in it of a non-existing process, it will report the process as running right from the start of the agent:A process is marked running if the procs map has at least one item:
This map is build/filled by updateProcesses:
Because the PID is specified by a
pid_file
we have a validPID
(int32
). This results in a validProcess
fromp.createProcess(pid)
, regardless whether the process exists or not. ThisProcess
is inserted into theprocs
map resulting in a map that has 1 or more entries. So if you provide apid_file
that has a number in it,procstat
will always returnrunning=1i
.In this PR I assume processes without name are rare and the chance that you want to monitor a process with no name is even rarer, a process without (or empty) name is seen as not running.