about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorarg@10ksloc.org <unknown>2006-08-02 12:33:24 +0200
committerarg@10ksloc.org <unknown>2006-08-02 12:33:24 +0200
commit0cf3ba0eab1e3b05515907b29fbb739321a7cbed (patch)
tree3170d2dda9fa83da04c0aa3dfda82654a0e42e98
parent1d852259526e41ebaad7325ee42c118b1cc12f71 (diff)
downloaddwm-0cf3ba0eab1e3b05515907b29fbb739321a7cbed.tar.gz
dwm is now exit, if stdin is closed due broken pipe
-rw-r--r--main.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/main.c b/main.c
index f09307b..86d72fa 100644
--- a/main.c
+++ b/main.c
@@ -165,7 +165,6 @@ main(int argc, char *argv[])
 	int i;
 	unsigned int mask;
 	fd_set rd;
-	Bool readin = True;
 	Window w;
 	XEvent ev;
 	XSetWindowAttributes wa;
@@ -252,8 +251,7 @@ main(int argc, char *argv[])
 	/* 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 @@ main(int argc, char *argv[])
 						(handler[ev.type])(&ev); /* call handler */
 				}
 			}
-			if(readin && FD_ISSET(STDIN_FILENO, &rd)) {
-				readin = NULL != fgets(stext, sizeof(stext), stdin);
-				if(readin)
-					stext[strlen(stext) - 1] = 0;
+			if(FD_ISSET(STDIN_FILENO, &rd)) {
+				if(!fgets(stext, sizeof(stext), stdin))
+					break;
 				else 
-					strcpy(stext, "broken pipe");
+					stext[strlen(stext) - 1] = 0;
 				drawstatus();
 			}
 		}
g.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# Small program that runs the test cases for 'nim doc'.

import strutils, os

var
  failures = 0

proc test(dir: string; fixup = false) =
  putEnv("SOURCE_DATE_EPOCH", "100000")
  if execShellCmd("nim doc --project --index:on -o:$1/htmldocs $1/testproject.nim" % dir) != 0:
    quit("FAILURE: nim doc failed")

  if execShellCmd("nim buildIndex -o:$1/htmldocs/theindex.html $1/htmldocs" % [dir]) != 0:
    quit("FAILURE: nim buildIndex failed")

  for expected in walkDirRec(dir / "expected/"):
    let produced = expected.replace('\\', '/').replace("/expected/", "/htmldocs/")
    if not fileExists(produced):
      echo "FAILURE: files not found: ", produced
      inc failures
    elif readFile(expected) != readFile(produced):
      echo "FAILURE: files differ: ", produced
      discard execShellCmd("diff -uNdr " & expected & " " & produced)
      inc failures
      if fixup:
        copyFile(produced, expected)
    else:
      echo "SUCCESS: files identical: ", produced
  removeDir(dir / "htmldocs")

test("nimdoc/testproject", false)
if failures > 0: quit($failures & " failures occurred.")