From d30bba26eabeb44163d01d52d2c9ca1a960be623 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Mon, 7 Jul 2025 20:14:56 +0200 Subject: [PATCH] gbacktrace: Correctly wait for children on Unix The WIF* macros are supposed to be used with the status, not the pid. Also, only check the status if no error occurred, otherwise the value might be uninitialized. If an unrecoverable error occurs, break the loop (could happen if SIGCHLD is ignored). --- glib/gbacktrace.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/glib/gbacktrace.c b/glib/gbacktrace.c index 8a5cf7076..713065914 100644 --- a/glib/gbacktrace.c +++ b/glib/gbacktrace.c @@ -290,7 +290,13 @@ g_on_error_stack_trace (const gchar *prg_name) while (1) { pid_t retval = waitpid (pid, &status, 0); - if (WIFEXITED (retval) || WIFSIGNALED (retval)) + if (retval == -1) + { + if (errno == EAGAIN || errno == EINTR) + continue; + break; + } + else if (WIFEXITED (status) || WIFSIGNALED (status)) break; } #else