summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <pwithnall@endlessos.org>2022-12-21 12:11:46 +0000
committerPhilip Withnall <pwithnall@endlessos.org>2022-12-21 12:11:46 +0000
commit379a98239175051a427c2d0d62d671b38b8dfb81 (patch)
treef4672e3ab66fd524393d22ae62bfeb8b47748097
parent9e2ad88455e422d9b2b6324388bbadabddbf1489 (diff)
downloadglib-379a98239175051a427c2d0d62d671b38b8dfb81.tar.gz
gmain: Define fallback values for siginfo_t constants for musl
musl doesn’t define them itself, presumably because they’re not defined in POSIX. glibc does define them. Thankfully, the values used in glibc match the values used internally in other musl macros. Define the values as a fallback. As a result of this, we can get rid of the `g_assert_if_reached()` checks in `siginfo_t_to_wait_status()`. This should fix catching signals from a subprocess when built against musl. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: #2852
-rw-r--r--glib/gmain.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/glib/gmain.c b/glib/gmain.c
index dba5f40e4..21e6b0ba0 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -79,6 +79,16 @@
#ifndef W_STOPCODE
#define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
#endif
+#ifndef WCOREFLAG
+/* musl doesn’t define WCOREFLAG while glibc does. Unfortunately, there’s no way
+ * to detect we’re building against musl, so just define it and hope.
+ * See https://git.musl-libc.org/cgit/musl/tree/include/sys/wait.h#n51 */
+#define WCOREFLAG 0x80
+#endif
+#ifndef __W_CONTINUED
+/* Same as above, for musl */
+#define __W_CONTINUED 0xffff
+#endif
#endif /* HAVE_PIDFD */
#ifdef G_OS_WIN32
@@ -5563,17 +5573,9 @@ siginfo_t_to_wait_status (const siginfo_t *info)
case CLD_KILLED:
return W_EXITCODE (0, info->si_status);
case CLD_DUMPED:
-#ifdef WCOREFLAG
return W_EXITCODE (0, info->si_status | WCOREFLAG);
-#else
- g_assert_not_reached ();
-#endif
case CLD_CONTINUED:
-#ifdef __W_CONTINUED
return __W_CONTINUED;
-#else
- g_assert_not_reached ();
-#endif
case CLD_STOPPED:
case CLD_TRAPPED:
default: