aboutsummaryrefslogtreecommitdiff
blob: 111895f0f1a4ca5efd4eb89c86eb99a3a9fa1d84 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
--- emacs-18.59-orig/src/ChangeLog
+++ emacs-18.59/src/ChangeLog
@@ -1,3 +1,9 @@
+2011-12-24  Ulrich Mueller  <ulm@gentoo.org>
+
+	* process.c: Include sys/wait.h if available.
+	Backported from Emacs 21.4.
+	* s-linux.h (HAVE_SYS_WAIT_H): Define.
+
 2010-03-11  Ulrich Mueller  <ulm@gentoo.org>
 
 	* Makefile (xmakefile): Call C preprocessor with -P option,
--- emacs-18.59-orig/src/process.c
+++ emacs-18.59/src/process.c
@@ -138,55 +138,37 @@
    On many systems, there is a structure defined for this.
    But on vanilla-ish USG systems there is not.  */
 
-#ifndef WAITTYPE
-#if !defined (BSD) && !defined (UNIPLUS) && !defined (STRIDE) && !(defined (HPUX) && !defined (NOMULTIPLEJOBS)) && !defined (HAVE_WAIT_HEADER)
-#define WAITTYPE int
-#define WIFSTOPPED(w) ((w&0377) == 0177)
-#define WIFSIGNALED(w) ((w&0377) != 0177 && (w&~0377) == 0)
-#define WIFEXITED(w) ((w&0377) == 0)
-#define WRETCODE(w) (w >> 8)
-#define WSTOPSIG(w) (w >> 8)
-#define WTERMSIG(w) (w & 0377)
-#ifndef WCOREDUMP
-#define WCOREDUMP(w) ((w&0200) != 0)
-#endif
-#else
-#ifdef BSD4_1
-#include <wait.h>
-#else
+#ifdef HAVE_SYS_WAIT_H	/* We have sys/wait.h with POSIXoid definitions. */
 #include <sys/wait.h>
-#endif /* not BSD 4.1 */
+#ifndef WCOREDUMP		/* not POSIX */
+#define WCOREDUMP(w) ((w) & 0x80)
+#endif
 
-#define WAITTYPE union wait
-#define WRETCODE(w) w.w_retcode
-#define WCOREDUMP(w) w.w_coredump
+#else  /* !HAVE_SYS_WAIT_H */
 
-#ifdef HPUX
-/* HPUX version 7 has broken definitions of these.  */
-#undef WTERMSIG
-#undef WSTOPSIG
+/* Note that sys/wait.h may still be included by stdlib.h or something
+   according to XPG.  */
+
+#undef WEXITSTATUS
+#define WEXITSTATUS(w) (((w) & 0xff00) >> 8)
+#undef WIFEXITED
+#define WIFEXITED(w) (WTERMSIG(w) == 0)
 #undef WIFSTOPPED
+#define WIFSTOPPED(w) (((w) & 0xff) == 0x7f)
 #undef WIFSIGNALED
-#undef WIFEXITED
-#endif
+#define WIFSIGNALED(w) (!WIFSTOPPED(w) && !WIFEXITED(w))
+#undef WSTOPSIG
+#define WSTOPSIG(w) WEXITSTATUS(w)
+#undef WTERMSIG
+#define WTERMSIG(w) ((w) & 0x7f)
+#undef WCOREDUMP
+#define WCOREDUMP(w) ((w) & 0x80)
+#endif /* HAVE_SYS_WAIT_H */
 
-#ifndef WTERMSIG
-#define WTERMSIG(w) w.w_termsig
-#endif
-#ifndef WSTOPSIG
-#define WSTOPSIG(w) w.w_stopsig
-#endif
-#ifndef WIFSTOPPED
-#define WIFSTOPPED(w) (WTERMSIG (w) == 0177)
-#endif
-#ifndef WIFSIGNALED
-#define WIFSIGNALED(w) (WTERMSIG (w) != 0177 && (WSTOPSIG (w)) == 0)
-#endif
-#ifndef WIFEXITED
-#define WIFEXITED(w) (WTERMSIG (w) == 0)
-#endif
-#endif /* BSD or UNIPLUS or STRIDE */
-#endif /* no WAITTYPE */
+#undef WAITTYPE
+#define WAITTYPE int
+#undef WRETCODE
+#define WRETCODE(w) WEXITSTATUS (w)
 
 extern errno;
 extern sys_nerr;
--- emacs-18.59-orig/src/s-linux.h
+++ emacs-18.59/src/s-linux.h
@@ -166,6 +166,7 @@
 #define NO_SIOCTL_H		/* don't have sioctl.h */
 #define SYSV_SYSTEM_DIR		/* use dirent.h */
 #define USG_SYS_TIME		/* use sys/time.h, not time.h */
+#define HAVE_SYS_WAIT_H		/* we have sys/wait.h */
 
 #define POSIX			/* affects only getpagesize.h */
 #define POSIX_SIGNALS		/* uses sigaction from sys_signal */