tif stdin writer stops working, dwm consumed much IO load because it still trie… | |
git clone git://src.adamsgaard.dk/dwm | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 5b44976a2d8bdd1397727663ce019374d6b2730a | |
parent 6475be926bef4916ce632988a2fa408a637babc7 | |
Author: Anselm R. Garbe <[email protected]> | |
Date: Fri, 14 Jul 2006 17:30:37 +0200 | |
if stdin writer stops working, dwm consumed much IO load because it still tried… | |
Diffstat: | |
M main.c | 10 +++++++--- | |
1 file changed, 7 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/main.c b/main.c | |
t@@ -190,6 +190,7 @@ main(int argc, char *argv[]) | |
fd_set rd; | |
XSetWindowAttributes wa; | |
unsigned int mask; | |
+ Bool readstdin = True; | |
Window w; | |
XEvent ev; | |
t@@ -283,7 +284,8 @@ main(int argc, char *argv[]) | |
Mainloop: | |
while(running) { | |
FD_ZERO(&rd); | |
- FD_SET(STDIN_FILENO, &rd); | |
+ if(readstdin) | |
+ FD_SET(STDIN_FILENO, &rd); | |
FD_SET(ConnectionNumber(dpy), &rd); | |
i = select(ConnectionNumber(dpy) + 1, &rd, 0, 0, 0); | |
t@@ -299,11 +301,13 @@ Mainloop: | |
(handler[ev.type])(&ev); /* ca… | |
} | |
} | |
- if(FD_ISSET(STDIN_FILENO, &rd)) { | |
+ if(readstdin && FD_ISSET(STDIN_FILENO, &rd)) { | |
i = n = 0; | |
for(;;) { | |
if((i = getchar()) == EOF) { | |
- stext[0] = 0; | |
+ /* broken pipe/end of producer… | |
+ readstdin = False; | |
+ strcpy(stext, "broken pipe"); | |
goto Mainloop; | |
} | |
if(i == '\n' || n >= sizeof(stext) - 1) |