aewl

diff main.c @ 65:4f7b232bd72d

if stdin writer stops working, dwm consumed much IO load because it still tried to select on this fd, fixed
author Anselm R. Garbe <garbeam@wmii.de>
date Fri, 14 Jul 2006 17:30:37 +0200
parents 46d44d185464
children c2ddb9dbbd10
line diff
     1.1 --- a/main.c	Fri Jul 14 13:27:01 2006 +0200
     1.2 +++ b/main.c	Fri Jul 14 17:30:37 2006 +0200
     1.3 @@ -190,6 +190,7 @@
     1.4  	fd_set rd;
     1.5  	XSetWindowAttributes wa;
     1.6  	unsigned int mask;
     1.7 +	Bool readstdin = True;
     1.8  	Window w;
     1.9  	XEvent ev;
    1.10  
    1.11 @@ -283,7 +284,8 @@
    1.12  Mainloop:
    1.13  	while(running) {
    1.14  		FD_ZERO(&rd);
    1.15 -		FD_SET(STDIN_FILENO, &rd);
    1.16 +		if(readstdin)
    1.17 +			FD_SET(STDIN_FILENO, &rd);
    1.18  		FD_SET(ConnectionNumber(dpy), &rd);
    1.19  
    1.20  		i = select(ConnectionNumber(dpy) + 1, &rd, 0, 0, 0);
    1.21 @@ -299,11 +301,13 @@
    1.22  						(handler[ev.type])(&ev); /* call handler */
    1.23  				}
    1.24  			}
    1.25 -			if(FD_ISSET(STDIN_FILENO, &rd)) {
    1.26 +			if(readstdin && FD_ISSET(STDIN_FILENO, &rd)) {
    1.27  				i = n = 0;
    1.28  				for(;;) {
    1.29  					if((i = getchar()) == EOF) {
    1.30 -						stext[0] = 0;
    1.31 +						/* broken pipe/end of producer */
    1.32 +						readstdin = False;
    1.33 +						strcpy(stext, "broken pipe");
    1.34  						goto Mainloop;
    1.35  					}
    1.36  					if(i == '\n' || n >= sizeof(stext) - 1)