process.c: Close events are processed too late

Compiling with macro -DEXITFREE opens a code path on which the event
loop is used after it was teared down, because not all close events
were processed yet.
This commit is contained in:
oni-link 2016-05-27 19:03:22 +02:00
parent 677eae6b0f
commit 1e593436d0

View File

@ -126,8 +126,10 @@ void process_teardown(Loop *loop) FUNC_ATTR_NONNULL_ALL
}
}
// Wait until all children exit
LOOP_PROCESS_EVENTS_UNTIL(loop, loop->events, -1, kl_empty(loop->children));
// Wait until all children exit and all close events are processed.
LOOP_PROCESS_EVENTS_UNTIL(
loop, loop->events, -1,
kl_empty(loop->children) && queue_empty(loop->events));
pty_process_teardown(loop);
}