# HG changeset patch # User arg@10ksloc.org # Date 1154514804 -7200 # Node ID a6a31e485fbd0566917552a486d879b0697e0302 # Parent f381e34158d9c368d7e17236940b8bc429d85ed2 dwm is now exit, if stdin is closed due broken pipe diff -r f381e34158d9 -r a6a31e485fbd main.c --- a/main.c Wed Aug 02 11:28:27 2006 +0200 +++ b/main.c Wed Aug 02 12:33:24 2006 +0200 @@ -165,7 +165,6 @@ int i; unsigned int mask; fd_set rd; - Bool readin = True; Window w; XEvent ev; XSetWindowAttributes wa; @@ -252,8 +251,7 @@ /* main event loop, reads status text from stdin as well */ while(running) { FD_ZERO(&rd); - if(readin) - FD_SET(STDIN_FILENO, &rd); + FD_SET(STDIN_FILENO, &rd); FD_SET(ConnectionNumber(dpy), &rd); i = select(ConnectionNumber(dpy) + 1, &rd, 0, 0, 0); @@ -269,12 +267,11 @@ (handler[ev.type])(&ev); /* call handler */ } } - if(readin && FD_ISSET(STDIN_FILENO, &rd)) { - readin = NULL != fgets(stext, sizeof(stext), stdin); - if(readin) + if(FD_ISSET(STDIN_FILENO, &rd)) { + if(!fgets(stext, sizeof(stext), stdin)) + break; + else stext[strlen(stext) - 1] = 0; - else - strcpy(stext, "broken pipe"); drawstatus(); } }