made error handling more proper
authorAnselm R. Garbe <garbeam@gmail.com>
Fri, 02 Nov 2007 17:04:40 +0100
changeset 1052 aef45cdbcb11
parent 1051 3f8cdff6da5d
child 1053 9990c1b25ceb
made error handling more proper
dwm.c
--- a/dwm.c	Fri Nov 02 16:57:52 2007 +0100
+++ b/dwm.c	Fri Nov 02 17:04:40 2007 +0100
@@ -1302,8 +1302,13 @@
 		if(FD_ISSET(STDIN_FILENO, &rd)) {
 			if(stext == fgets(stext, sizeof stext - 1, stdin))
 				stext[strlen(stext) - 1] = '\0'; /* remove tailing '\n' */
-			else
-				strncpy(stext, strerror(errno), sizeof stext - 1);
+			else {
+				readin = False;
+				if(feof(stdin))
+					strncpy(stext, "EOF", 4);
+				else /* error occured */
+					strncpy(stext, strerror(errno), sizeof stext - 1);
+			}
 			drawbar();
 		}
 		while(XPending(dpy)) {