mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Taskbar: Wait on all waitable children in SIGCHLD handler
We need to call waitpid until no more waitable children are available. This is necessary because SIGCHLD signals may coalesce into one when multiple children terminate almost simultaneously. Also, switch to EventLoop's asynchronous signal handling mechanism, which allows more complex operations in the signal handler.
This commit is contained in:
parent
d6174f9c79
commit
f68115aba3
Notes:
sideshowbarker
2024-07-19 01:06:04 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/f68115aba31 Pull-request: https://github.com/SerenityOS/serenity/pull/4300
2 changed files with 7 additions and 4 deletions
|
@ -74,6 +74,8 @@ public:
|
|||
|
||||
bool focus_debugging_enabled() const { return m_focus_debugging_enabled; }
|
||||
|
||||
Core::EventLoop& event_loop() { return *m_event_loop; }
|
||||
|
||||
private:
|
||||
Application(int argc, char** argv);
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "TaskbarWindow.h"
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
@ -38,10 +39,10 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
signal(SIGCHLD, [](int signo) {
|
||||
(void)signo;
|
||||
wait(nullptr);
|
||||
app->event_loop().register_signal(SIGCHLD, [](int) {
|
||||
// Wait all available children
|
||||
while (waitpid(-1, nullptr, WNOHANG) > 0)
|
||||
;
|
||||
});
|
||||
|
||||
if (pledge("stdio shared_buffer accept proc exec rpath", nullptr) < 0) {
|
||||
|
|
Loading…
Reference in a new issue