diff --git a/Utilities/socketxx/socket++/fork.cpp b/Utilities/socketxx/socket++/fork.cpp index 4b580aa1f..9838c2bc8 100644 --- a/Utilities/socketxx/socket++/fork.cpp +++ b/Utilities/socketxx/socket++/fork.cpp @@ -38,9 +38,12 @@ Fork::KillForks::~KillForks () // First, kill all children whose kill_child flag is set. // Second, wait for other children to die. { - for (ForkProcess* cur = Fork::ForkProcess::list; cur; cur = cur->next) - if (cur->kill_child) + + for (ForkProcess* cur = Fork::ForkProcess::list; cur != nullptr; cur = cur->next) + if (cur->kill_child) { delete cur; + break; + } while (Fork::ForkProcess::list && wait (nullptr) > 0) {} }