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
|
--- src/conky.h.old 2005-11-16 18:45:32.000000000 -0500
+++ src/conky.h 2005-11-24 23:06:25.046033576 -0500
@@ -209,8 +209,8 @@
int use_spacer;
-char *tmpstring1;
-char *tmpstring2;
+char tmpstring1[TEXT_BUFFER_SIZE];
+char tmpstring2[TEXT_BUFFER_SIZE];
#ifdef X11
/* in x11.c */
--- src/conky.c.old 2005-11-16 19:32:39.000000000 -0500
+++ src/conky.c 2005-11-24 23:03:03.675646528 -0500
@@ -3,7 +3,7 @@
*
* This program is licensed under BSD license, read COPYING
*
- * $Id: conky-1.3.4-miscbug.patch,v 1.1 2005/11/25 08:36:08 dragonheart Exp $
+ * $Id: conky-1.3.4-miscbug.patch,v 1.1 2005/11/25 08:36:08 dragonheart Exp $
*/
#include "conky.h"
@@ -34,6 +34,9 @@
#define MAIL_FILE "$MAIL"
#define MAX_IF_BLOCK_DEPTH 5
+/* #define SIGNAL_BLOCKING */
+#undef SIGNAL_BLOCKING
+
#ifdef X11
/* alignments */
@@ -4060,6 +4063,15 @@
static void main_loop()
{
+#ifdef SIGNAL_BLOCKING
+ sigset_t newmask, oldmask;
+
+ sigemptyset(&newmask);
+ sigaddset(&newmask,SIGINT);
+ sigaddset(&newmask,SIGTERM);
+ sigaddset(&newmask,SIGUSR1);
+#endif
+
#ifdef X11
Region region = XCreateRegion();
#endif /* X11 */
@@ -4067,6 +4079,13 @@
info.looped = 0;
while (total_run_times == 0 || info.looped < total_run_times - 1) {
info.looped++;
+
+#ifdef SIGNAL_BLOCKING
+ /* block signals. we will inspect for pending signals later */
+ if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0)
+ CRIT_ERR("unable to sigprocmask()");
+#endif
+
#ifdef X11
XFlush(display);
@@ -4287,7 +4306,12 @@
}
#endif /* X11 */
- /* inspect pending signal prior to entering next loop */
+#ifdef SIGNAL_BLOCKING
+ /* unblock signals of interest and let handler fly */
+ if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0)
+ CRIT_ERR("unable to sigprocmask()");
+#endif
+
switch(g_signal_pending) {
case SIGUSR1:
{
@@ -4964,6 +4988,8 @@
int main(int argc, char **argv)
{
+ struct sigaction act, oact;
+
g_signal_pending=0;
memset(&info, 0, sizeof(info) );
@@ -5058,11 +5084,6 @@
init_X11();
#endif /* X11 */
- tmpstring1 = (char *)
- malloc(TEXT_BUFFER_SIZE);
- tmpstring2 = (char *)
- malloc(TEXT_BUFFER_SIZE);
-
/* load current_config or CONFIG_FILE */
#ifdef CONFIG_FILE
@@ -5241,16 +5262,22 @@
}
/* Set signal handlers */
- if ( signal(SIGINT,signal_handler) == SIG_ERR ||
- signal(SIGUSR1,signal_handler) == SIG_ERR ||
- signal(SIGTERM,signal_handler) == SIG_ERR )
+ act.sa_handler = signal_handler;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+#ifdef SA_RESTART
+ act.sa_flags |= SA_RESTART;
+#endif
+
+ if ( sigaction(SIGINT,&act,&oact) < 0 ||
+ sigaction(SIGUSR1,&act,&oact) < 0 ||
+ sigaction(SIGTERM,&act,&oact) < 0 )
{
ERR("error setting signal handler: %s", strerror(errno) );
}
main_loop();
- free(tmpstring1);
- free(tmpstring2);
+
return 0;
}
|