Increase child cleanup timeout from 5 to 10 seconds, improved shutdown handling

This commit is contained in:
Thulinma 2018-02-08 15:35:48 +01:00
parent 3e6b7fc9e8
commit 42b9ec08af

View file

@ -99,28 +99,27 @@ void Util::Procs::exit_handler() {
return;
}
WARN_MSG("Sending SIGINT to remaining %d children", (int)listcopy.size());
//send sigint to all remaining
if (!listcopy.empty()) {
for (it = listcopy.begin(); it != listcopy.end(); it++) {
DEBUG_MSG(DLVL_DEVEL, "SIGINT %d", *it);
kill(*it, SIGINT);
}
}
INFO_MSG("Waiting up to 5 seconds for %d children to terminate.", (int)listcopy.size());
INFO_MSG("Sending SIGINT and waiting up to 10 seconds for %d children to terminate.", (int)listcopy.size());
waiting = 0;
//wait up to 5 seconds for applications to shut down
while (!listcopy.empty() && waiting <= 250) {
//wait up to 10 seconds for applications to shut down
while (!listcopy.empty() && waiting <= 500) {
bool doWait = true;
for (it = listcopy.begin(); it != listcopy.end(); it++) {
if (!childRunning(*it)) {
listcopy.erase(it);
doWait = false;
break;
}
if (!listcopy.empty()) {
Util::wait(20);
++waiting;
}
if (doWait && !listcopy.empty()) {
if ((waiting % 50) == 0){
for (it = listcopy.begin(); it != listcopy.end(); it++) {
INFO_MSG("SIGINT %d", *it);
kill(*it, SIGINT);
}
}
Util::wait(20);
++waiting;
}
}
if (listcopy.empty()) {