if stdin writer stops working, dwm consumed much IO load because it still tried to select on this fd, fixed 5b44976a
Anselm R. Garbe · 2006-07-14 17:30 1 file(s) · +7 −3
main.c +7 −3
190 190
	fd_set rd;
191 191
	XSetWindowAttributes wa;
192 192
	unsigned int mask;
193 +
	Bool readstdin = True;
193 194
	Window w;
194 195
	XEvent ev;
195 196
283 284
Mainloop:
284 285
	while(running) {
285 286
		FD_ZERO(&rd);
286 -
		FD_SET(STDIN_FILENO, &rd);
287 +
		if(readstdin)
288 +
			FD_SET(STDIN_FILENO, &rd);
287 289
		FD_SET(ConnectionNumber(dpy), &rd);
288 290
289 291
		i = select(ConnectionNumber(dpy) + 1, &rd, 0, 0, 0);
299 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 305
				i = n = 0;
304 306
				for(;;) {
305 307
					if((i = getchar()) == EOF) {
306 -
						stext[0] = 0;
308 +
						/* broken pipe/end of producer */
309 +
						readstdin = False;
310 +
						strcpy(stext, "broken pipe");
307 311
						goto Mainloop;
308 312
					}
309 313
					if(i == '\n' || n >= sizeof(stext) - 1)