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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
$NetBSD: patch-ab,v 1.3 2013/01/11 23:36:16 joerg Exp $
--- uwm.c.orig 1988-10-23 13:21:55.000000000 +0000
+++ uwm.c
@@ -41,9 +41,25 @@ char *ProgramName;
#include "uwm.h"
#include <ctype.h>
+#include <signal.h>
+
+#ifdef CSRG_BASED
+#undef MIN
+#undef MAX
+#include <sys/param.h>
+#if defined(BSD) && BSD >= 199306
+#define HAVE_MKSTEMP
+#endif
+#endif
+
+#ifdef X_NOT_STDC_ENV
+char *malloc();
+#endif
+
+static void SetEnvironment (void);
+void LoadXDefaults (void);
#ifdef PROFIL
-#include <signal.h>
/*
* Dummy handler for profiling.
*/
@@ -53,6 +69,27 @@ ptrap()
}
#endif
+#ifdef SIGCHLD
+#include <sys/wait.h>
+/*
+ * clear (probably inherited) children which are dead or will die.
+ */
+clear_children()
+{
+ int status, pid;
+
+ do {
+#ifdef CSRG_BASED
+ pid = wait3(&status, WNOHANG, (struct rusage *) 0);
+#else /* SVR4 */
+ pid = waitpid(-1, &status, WNOHANG);
+#endif
+ } while (pid != 0 && pid != -1);
+
+ signal(SIGCHLD, clear_children);
+}
+#endif
+
#define gray_width 16
#define gray_height 16
static char gray_bits[] = {
@@ -103,7 +140,6 @@ char **environ;
GC gc; /* graphics context for gray background */
XImage grayimage; /* for gray background */
XGCValues xgc; /* to create font GCs */
- char *malloc();
Bool fallbackMFont = False, /* using default GC font for menus, */
fallbackPFont = False, /* popups, */
fallbackIFont = False; /* icons */
@@ -115,6 +151,10 @@ char **environ;
#ifdef PROFIL
signal(SIGTERM, ptrap);
#endif
+#ifdef SIGCHLD
+ /* no zombies */
+ clear_children();
+#endif
/*
* Set up internal defaults.
@@ -369,7 +409,7 @@ char **environ;
if (IFontInfo == NULL) {
fprintf(stderr, "uwm: Unable to open icon font '%s', using server default.\n",
IFontName);
- IFontInfo = XQueryFont(dpy, DefaultGC(dpy, scr)->gid);
+ IFontInfo = XQueryFont(dpy, XGContextFromGC(DefaultGC(dpy, scr)));
fallbackIFont = True;
}
PFontInfo = XLoadQueryFont(dpy, PFontName);
@@ -379,7 +419,7 @@ char **environ;
if (fallbackIFont)
PFontInfo = IFontInfo;
else
- PFontInfo = XQueryFont(dpy, DefaultGC(dpy, scr)->gid);
+ PFontInfo = XQueryFont(dpy, XGContextFromGC(DefaultGC(dpy, scr)));
fallbackPFont = True;
}
MFontInfo = XLoadQueryFont(dpy, MFontName);
@@ -389,7 +429,7 @@ char **environ;
if (fallbackIFont || fallbackPFont)
MFontInfo = fallbackPFont ? PFontInfo : IFontInfo;
else
- MFontInfo = XQueryFont(dpy, DefaultGC(dpy, scr)->gid);
+ MFontInfo = XQueryFont(dpy, XGContextFromGC(DefaultGC(dpy, scr)));
fallbackMFont = True;
}
@@ -685,7 +725,11 @@ char **environ;
*/
InitBindings()
{
+#ifdef HAVE_MKSTEMP
+ int fd;
+#else
char *mktemp();
+#endif
char *tempfile; /* Temporary filename. */
register FILE *fp; /* Temporary file pointer. */
register char **ptr; /* Default bindings string array pointer. */
@@ -699,15 +743,26 @@ InitBindings()
exit (1);
}
strcpy (tempfile, TEMPFILE);
+#ifdef HAVE_MKSTEMP
+ if ((fd = mkstemp(tempfile)) < 0 || (fp = fdopen(fd, "r+")) == NULL) {
+ perror("uwm: cannot create temp file");
+ exit(1);
+ }
+#else
sfilename = mktemp(tempfile);
if ((fp = fopen(tempfile, "w")) == NULL) {
perror("uwm: cannot create temp file");
exit(1);
}
+#endif
for (ptr = DefaultBindings; *ptr; ptr++) {
fputs(*ptr, fp);
fputc('\n', fp);
}
+#ifdef HAVE_MKSTEMP
+ rewind(fp);
+ yyin = fp;
+#else
fclose(fp);
/*
@@ -717,6 +772,7 @@ InitBindings()
perror("uwm: cannot open temp file");
exit(1);
}
+#endif
Lineno = 1;
yyparse();
fclose(yyin);
@@ -998,7 +1054,7 @@ static int parse_boolean (s)
return -1;
}
-LoadXDefaults ()
+void LoadXDefaults (void)
{
Keyword *k;
char *option;
@@ -1068,7 +1124,7 @@ char **newenviron;
* make a new copy of environment that has room for DISPLAY
*/
-SetEnvironment ()
+static void SetEnvironment (void)
{
int nenvvars;
char **newPtr, **oldPtr;
|