# HG changeset patch # User Anselm R. Garbe # Date 1152891037 -7200 # Node ID 4f7b232bd72d3c7a7246cdf2cf84ab3efded6f23 # Parent 46d44d1854640d0a824c85638ee49a2a8c8a0e8f if stdin writer stops working, dwm consumed much IO load because it still tried to select on this fd, fixed diff -r 46d44d185464 -r 4f7b232bd72d main.c --- a/main.c Fri Jul 14 13:27:01 2006 +0200 +++ b/main.c Fri Jul 14 17:30:37 2006 +0200 @@ -190,6 +190,7 @@ fd_set rd; XSetWindowAttributes wa; unsigned int mask; + Bool readstdin = True; Window w; XEvent ev; @@ -283,7 +284,8 @@ 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); @@ -299,11 +301,13 @@ (handler[ev.type])(&ev); /* call handler */ } } - 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)