summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-14 17:30:37 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-14 17:30:37 +0200
commit5b44976a2d8bdd1397727663ce019374d6b2730a (patch)
tree2376691581648321ea368e5846541a1ac08abe71
parentremoved a bottleneck (diff)
downloaddwm-5b44976a2d8bdd1397727663ce019374d6b2730a.tar.gz
dwm-5b44976a2d8bdd1397727663ce019374d6b2730a.zip
if stdin writer stops working, dwm consumed much IO load because it still tried to select on this fd, fixed
-rw-r--r--main.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/main.c b/main.c
index 42c9d8a..b59ff96 100644
--- a/main.c
+++ b/main.c
@@ -190,6 +190,7 @@ main(int argc, char *argv[])
190 fd_set rd; 190 fd_set rd;
191 XSetWindowAttributes wa; 191 XSetWindowAttributes wa;
192 unsigned int mask; 192 unsigned int mask;
193 Bool readstdin = True;
193 Window w; 194 Window w;
194 XEvent ev; 195 XEvent ev;
195 196
@@ -283,7 +284,8 @@ main(int argc, char *argv[])
283Mainloop: 284Mainloop:
284 while(running) { 285 while(running) {
285 FD_ZERO(&rd); 286 FD_ZERO(&rd);
286 FD_SET(STDIN_FILENO, &rd); 287 if(readstdin)
288 FD_SET(STDIN_FILENO, &rd);
287 FD_SET(ConnectionNumber(dpy), &rd); 289 FD_SET(ConnectionNumber(dpy), &rd);
288 290
289 i = select(ConnectionNumber(dpy) + 1, &rd, 0, 0, 0); 291 i = select(ConnectionNumber(dpy) + 1, &rd, 0, 0, 0);
@@ -299,11 +301,13 @@ Mainloop:
299 (handler[ev.type])(&ev); /* call handler */ 301 (handler[ev.type])(&ev); /* call handler */
300 } 302 }
301 } 303 }
302 if(FD_ISSET(STDIN_FILENO, &rd)) { 304 if(readstdin && FD_ISSET(STDIN_FILENO, &rd)) {
303 i = n = 0; 305 i = n = 0;
304 for(;;) { 306 for(;;) {
305 if((i = getchar()) == EOF) { 307 if((i = getchar()) == EOF) {
306 stext[0] = 0; 308 /* broken pipe/end of producer */
309 readstdin = False;
310 strcpy(stext, "broken pipe");
307 goto Mainloop; 311 goto Mainloop;
308 } 312 }
309 if(i == '\n' || n >= sizeof(stext) - 1) 313 if(i == '\n' || n >= sizeof(stext) - 1)