Fixed a race condition in process status checking.
This commit is contained in:
parent
e2e3f64d89
commit
10dc56c338
1 changed files with 4 additions and 2 deletions
|
@ -621,7 +621,9 @@ bool Util::Procs::isActive(std::string name){
|
||||||
std::map<pid_t, std::string>::iterator it;
|
std::map<pid_t, std::string>::iterator it;
|
||||||
for (it = plist.begin(); it != plist.end(); it++){
|
for (it = plist.begin(); it != plist.end(); it++){
|
||||||
if (( *it).second == name){
|
if (( *it).second == name){
|
||||||
return true;
|
if (kill(( *it).first, 0) == 0){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -629,7 +631,7 @@ bool Util::Procs::isActive(std::string name){
|
||||||
|
|
||||||
/// Returns true if a process with this PID is currently active.
|
/// Returns true if a process with this PID is currently active.
|
||||||
bool Util::Procs::isActive(pid_t name){
|
bool Util::Procs::isActive(pid_t name){
|
||||||
return (plist.count(name) == 1);
|
return (plist.count(name) == 1) && (kill(name, 0) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets PID for this named process, if active.
|
/// Gets PID for this named process, if active.
|
||||||
|
|
Loading…
Add table
Reference in a new issue