Fixed a few bugs in Util::Procs SIGCHILD handling / isActive function.
This commit is contained in:
parent
31f4509e26
commit
2d0f25b7be
1 changed files with 6 additions and 6 deletions
|
@ -127,15 +127,12 @@ void Util::Procs::childsig_handler(int signum){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG >= 1
|
#if DEBUG >= 5
|
||||||
std::string pname = plist[ret];
|
std::string pname = plist[ret];
|
||||||
#endif
|
#endif
|
||||||
plist.erase(ret);
|
plist.erase(ret);
|
||||||
#if DEBUG >= 5
|
#if DEBUG >= 5
|
||||||
if (isActive(pname)){
|
if (!isActive(pname)){
|
||||||
Stop(pname);
|
|
||||||
} else{
|
|
||||||
//can this ever happen?
|
|
||||||
std::cerr << "Process " << pname << " fully terminated." << std::endl;
|
std::cerr << "Process " << pname << " fully terminated." << std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -674,11 +671,14 @@ int Util::Procs::Count(){
|
||||||
|
|
||||||
/// Returns true if a process by this name is currently active.
|
/// Returns true if a process by this name is currently active.
|
||||||
bool Util::Procs::isActive(std::string name){
|
bool Util::Procs::isActive(std::string name){
|
||||||
|
std::map<pid_t, std::string> listcopy = plist;
|
||||||
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 = listcopy.begin(); it != listcopy.end(); it++){
|
||||||
if (( *it).second == name){
|
if (( *it).second == name){
|
||||||
if (kill(( *it).first, 0) == 0){
|
if (kill(( *it).first, 0) == 0){
|
||||||
return true;
|
return true;
|
||||||
|
}else{
|
||||||
|
plist.erase(( *it).first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue