42daa4642a781e88f86984a04d826d845679fd1c
markd
  Thu Jul 25 21:40:11 2013 -0700
enable SIGPIPE on linefile gzip subprocesses to allow closing the reading of compressed files before EOF is reached
diff --git src/lib/tests/makefile src/lib/tests/makefile
index 4825796..ded448d 100644
--- src/lib/tests/makefile
+++ src/lib/tests/makefile
@@ -30,31 +30,31 @@
 
 htmlExpandUrlTest: htmlExpandUrlTest.o ${MYLIBS} mkdirs
 	${CC} ${COPT} -o ${BIN_DIR}/htmlExpandUrlTest htmlExpandUrlTest.o ${MYLIBS} ${L}
 	${STRIP} ${BIN_DIR}/htmlExpandUrlTest${EXE}
 	${BIN_DIR}/htmlExpandUrlTest > output/htmlExpandUrlTest 2>&1
 	diff expected/htmlExpandUrlTest output/htmlExpandUrlTest
 
 htmlPageTest: htmlPageTest.o ${MYLIBS} mkdirs
 	${CC} ${COPT} -o ${BIN_DIR}/htmlPageTest htmlPageTest.o ${MYLIBS} ${L}
 	${STRIP} ${BIN_DIR}/htmlPageTest${EXE}
 	${BIN_DIR}/htmlPageTest input/google.html > output/google.out
 	diff expected/google.out output/google.out
 
 pipelineTests: 	pipelineWrite pipelineWriteMult pipelineWriteFd \
 		pipelineRead pipelineReadMult pipelineReadFd pipelineReadMem \
-		pipelineExitCode pipelineWriteErr pipelineExecError
+		pipelineExitCode pipelineWriteErr pipelineExecError pipelineSigpipe
 
 pipelineWrite: ${BIN_DIR}/pipelineTester mkdirs
 	${BIN_DIR}/pipelineTester -write -pipeData=input/simple1.txt -otherEnd=output/$@.out.gz "gzip -1"
 	gunzip -c output/$@.out.gz > output/$@.out
 	diff -b input/simple1.txt output/$@.out
 
 # add come junk to make sure output gets truncated
 pipelineWriteMult: ${BIN_DIR}/pipelineTester mkdirs
 	cat input/google.html > output/$@.wc
 	${BIN_DIR}/pipelineTester -write -pipeData=input/simple1.txt -otherEnd=output/$@.wc "gzip -1" "gzip -dc" "wc"
 	diff -b expected/simple1.wc output/$@.wc
 
 pipelineWriteFd: ${BIN_DIR}/pipelineTester mkdirs
 	${BIN_DIR}/pipelineTester -fdApi -write -pipeData=input/simple1.txt -otherEnd=output/$@.out.gz "gzip -1"
 	gunzip -c output/$@.out.gz > output/$@.out
@@ -87,30 +87,35 @@
 # the second's stdout should make it to the end of the pipe.  Since order
 # of writes to stderr is determined by process scheduling and when a process
 # terminates due to SIGPIPE, just check that stderr was not empty, don't
 # check contents.
 pipelineWriteErr: ${BIN_DIR}/pipelineTester mkdirs
 	${BIN_DIR}/pipelineTester -write -otherEnd=output/$@.out -stderr=output/$@.err "sh -c 'echo OUT; echo ERR >&2'"  "sh -c 'echo OUT2; echo ERR2 >&2'"
 	diff -b expected/$@.out output/$@.out
 	test -s output/$@.err
 
 # exec a non-existent program
 pipelineExecError: ${BIN_DIR}/pipelineTester mkdirs
 	if ${BIN_DIR}/pipelineTester -write -stderr=output/$@.err "./thatDoesNotCompute" 2> output/$@.parent.err ; then false else true ; fi
 	diff -b expected/$@.err output/$@.err
 	diff -b expected/$@.parent.err output/$@.parent.err
 
+# test setting SIGPIPE by generating lots of output and then prematurely closing the
+# pipe
+pipelineSigpipe: ${BIN_DIR}/pipelineTester mkdirs
+	${BIN_DIR}/pipelineTester -sigpipe -maxNumLines=3 -pipeData=/dev/null "awk 'BEGIN {while (1) {print "foo"}}'"
+
 ${BIN_DIR}/pipelineTester:  mkdirs pipelineTester.o ${MYLIBS}
 	${CC} ${COPT} -o ${BIN_DIR}/pipelineTester pipelineTester.o ${MYLIBS} ${L}
 
 
 dyStringTest: ${BIN_DIR}/dyStringTester mkdirs
 	${BIN_DIR}/dyStringTester
 
 ${BIN_DIR}/dyStringTester:  mkdirs dyStringTester.o ${MYLIBS}
 	${CC} ${COPT} -o ${BIN_DIR}/dyStringTester dyStringTester.o ${MYLIBS} ${L}
 
 
 mimeTests: mime1 mime2 mime3 mime4 mimeBin mime5 mimeAltHead mimeAutoBoundary mimeBlat
 
 ${BIN_DIR}/mimeTester:  mkdirs mimeTester.o ${MYLIBS}
 	${CC} ${COPT} -o ${BIN_DIR}/mimeTester mimeTester.o ${MYLIBS} ${L}