From 2d0f25b7be736d697a1bd6bae53ef31eb037aeef Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 30 Sep 2013 13:25:20 +0200 Subject: [PATCH] Fixed a few bugs in Util::Procs SIGCHILD handling / isActive function. --- lib/procs.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/procs.cpp b/lib/procs.cpp index 2293417e..684ef712 100644 --- a/lib/procs.cpp +++ b/lib/procs.cpp @@ -127,15 +127,12 @@ void Util::Procs::childsig_handler(int signum){ return; } -#if DEBUG >= 1 +#if DEBUG >= 5 std::string pname = plist[ret]; #endif plist.erase(ret); #if DEBUG >= 5 - if (isActive(pname)){ - Stop(pname); - } else{ - //can this ever happen? + if (!isActive(pname)){ std::cerr << "Process " << pname << " fully terminated." << std::endl; } #endif @@ -674,11 +671,14 @@ int Util::Procs::Count(){ /// Returns true if a process by this name is currently active. bool Util::Procs::isActive(std::string name){ + std::map listcopy = plist; std::map::iterator it; - for (it = plist.begin(); it != plist.end(); it++){ + for (it = listcopy.begin(); it != listcopy.end(); it++){ if (( *it).second == name){ if (kill(( *it).first, 0) == 0){ return true; + }else{ + plist.erase(( *it).first); } } }