diff options
| author | Anselm R. Garbe <garbeam@wmii.de> | 2006-07-14 17:30:37 +0200 |
|---|---|---|
| committer | Anselm R. Garbe <garbeam@wmii.de> | 2006-07-14 17:30:37 +0200 |
| commit | 5b44976a2d8bdd1397727663ce019374d6b2730a (patch) | |
| tree | 2376691581648321ea368e5846541a1ac08abe71 /main.c | |
| parent | removed a bottleneck (diff) | |
| download | dwm-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
Diffstat (limited to '')
| -rw-r--r-- | main.c | 10 |
1 files changed, 7 insertions, 3 deletions
| @@ -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[]) | |||
| 283 | Mainloop: | 284 | Mainloop: |
| 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) |
