File: 0008-Add-fallback-for-missing-SA_NOCLDWAIT.patch

package info (click to toggle)
mupdf 1.25.1%2Bds1-7
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 21,644 kB
  • sloc: ansic: 270,937; python: 20,709; java: 6,916; javascript: 1,865; makefile: 1,130; xml: 550; sh: 430; cpp: 325; cs: 313; awk: 10; sed: 7; lisp: 3
file content (46 lines) | stat: -rw-r--r-- 1,077 bytes parent folder | download | duplicates (2)
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