kit/ForKit.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
New commits: commit 93858c5b9e7c61c33ac3c45710a351bf22f481d9 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sun Jan 29 20:19:23 2017 -0500 wsd: forkit removes jails after reaping dead children Change-Id: Ia4b8dd85b41fa59ececbed85e35616fee6a02254 Reviewed-on: https://gerrit.libreoffice.org/33678 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index ba3d548..b6383a8 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -182,21 +182,29 @@ static bool haveCorrectCapabilities() /// Check if some previously forked kids have died. static void cleanupChildren() { + std::vector<std::string> jails; Process::PID exitedChildPid; int status; while ((exitedChildPid = waitpid(-1, &status, WUNTRACED | WNOHANG)) > 0) { - if (childJails.find(exitedChildPid) != childJails.end()) + const auto it = childJails.find(exitedChildPid); + if (it != childJails.end()) { - LOG_INF("Child " << exitedChildPid << " has exited, removing its jail '" << childJails[exitedChildPid] << "'"); - FileUtil::removeFile(childJails[exitedChildPid], true); - childJails.erase(exitedChildPid); + LOG_INF("Child " << exitedChildPid << " has exited, removing its jail '" << it->second << "'."); + jails.emplace_back(it->second); + childJails.erase(it); } else { LOG_ERR("Unknown child " << exitedChildPid << " has exited"); } } + + // Now delete the jails. + for (const auto& path : jails) + { + FileUtil::removeFile(path, true); + } } static int createLibreOfficeKit(const std::string& childRoot, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits