1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
From: Victor Westerhuis <victor@westerhu.is>
Date: Sun, 15 Jan 2023 00:21:34 +0100
Subject: Add fallback for missing SA_NOCLDWAIT
GNU Hurd does not implement SA_NOCLDWAIT. It also does not
automatically reap zombies if SIGCHLD is ignored.
This fallback does not check for failures from waitpid(2), because
there is not much the program can do about them.
---
platform/gl/gl-main.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
--- a/platform/gl/gl-main.c
+++ b/platform/gl/gl-main.c
@@ -3083,6 +3083,11 @@
{
if (signal == SIGHUP)
reloadrequested = 1;
+#ifndef SA_NOCLDWAIT
+ else if (signal == SIGCHLD)
+ while (waitpid(-1, NULL, WNOHANG) > 0)
+ ;
+#endif
}
#endif
@@ -3100,11 +3105,18 @@
#ifndef _WIN32
/* Never wait for termination of child processes. */
+#ifdef SA_NOCLDWAIT
struct sigaction arg = {
.sa_handler=SIG_IGN,
.sa_flags=SA_NOCLDWAIT
};
sigaction(SIGCHLD, &arg, NULL);
+#else
+ struct sigaction arg = {
+ .sa_handler=signal_handler
+ };
+ sigaction(SIGCHLD, &arg, NULL);
+#endif
signal(SIGHUP, signal_handler);
#endif
|