aewl
diff main.c @ 162:a6a31e485fbd
dwm is now exit, if stdin is closed due broken pipe
author | arg@10ksloc.org |
---|---|
date | Wed, 02 Aug 2006 12:33:24 +0200 |
parents | 93012e947eae |
children | 21071ae1fe68 |
line diff
1.1 --- a/main.c Wed Aug 02 11:28:27 2006 +0200 1.2 +++ b/main.c Wed Aug 02 12:33:24 2006 +0200 1.3 @@ -165,7 +165,6 @@ 1.4 int i; 1.5 unsigned int mask; 1.6 fd_set rd; 1.7 - Bool readin = True; 1.8 Window w; 1.9 XEvent ev; 1.10 XSetWindowAttributes wa; 1.11 @@ -252,8 +251,7 @@ 1.12 /* main event loop, reads status text from stdin as well */ 1.13 while(running) { 1.14 FD_ZERO(&rd); 1.15 - if(readin) 1.16 - FD_SET(STDIN_FILENO, &rd); 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 @@ -269,12 +267,11 @@ 1.22 (handler[ev.type])(&ev); /* call handler */ 1.23 } 1.24 } 1.25 - if(readin && FD_ISSET(STDIN_FILENO, &rd)) { 1.26 - readin = NULL != fgets(stext, sizeof(stext), stdin); 1.27 - if(readin) 1.28 + if(FD_ISSET(STDIN_FILENO, &rd)) { 1.29 + if(!fgets(stext, sizeof(stext), stdin)) 1.30 + break; 1.31 + else 1.32 stext[strlen(stext) - 1] = 0; 1.33 - else 1.34 - strcpy(stext, "broken pipe"); 1.35 drawstatus(); 1.36 } 1.37 }