diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | main.c | 8 | ||||
-rw-r--r-- | test/Makefile.am | 6 | ||||
-rw-r--r-- | test/Makefile.in | 11 | ||||
-rw-r--r-- | test/Maketests | 5 | ||||
-rw-r--r-- | test/pipeio3.awk | 15 | ||||
-rw-r--r-- | test/pipeio3.ok | 6 |
7 files changed, 52 insertions, 4 deletions
@@ -1,3 +1,8 @@ +2013-10-17 Arnold D. Robbins <arnold@skeeve.com> + + * main.c (main): Ignore SIGPIPE. See the comment in the code. + Thanks to Alan Broder for reporting the issue. + 2013-10-16 Arnold D. Robbins <arnold@skeeve.com> Make -O work again. Turns out that C99 bool variables @@ -284,6 +284,14 @@ main(int argc, char **argv) #ifdef SIGBUS (void) signal(SIGBUS, catchsig); #endif +#ifdef SIGPIPE + /* + * Ignore SIGPIPE so that writes to pipes that fail don't + * kill the process but instead return -1 and set errno. + * That lets us print a fatal message instead of dieing suddenly. + */ + signal(SIGPIPE, SIG_IGN); +#endif (void) sigsegv_install_handler(catchsegv); #define STACK_SIZE (16*1024) diff --git a/test/Makefile.am b/test/Makefile.am index d0caeed7..abb3fb96 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -653,6 +653,8 @@ EXTRA_DIST = \ pipeio2.awk \ pipeio2.in \ pipeio2.ok \ + pipeio3.awk \ + pipeio3.ok \ posix.awk \ posix.in \ posix.ok \ @@ -972,8 +974,8 @@ BASIC_TESTS = \ zero2 zeroe0 zeroflag UNIX_TESTS = \ - fflush getlnhd localenl pid pipeio1 pipeio2 poundbang rtlen rtlen01 \ - space strftlng + fflush getlnhd localenl pid pipeio1 pipeio2 pipeio3 poundbang \ + rtlen rtlen01 space strftlng GAWK_EXT_TESTS = \ aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \ diff --git a/test/Makefile.in b/test/Makefile.in index 5ddd9e32..9676494d 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -871,6 +871,8 @@ EXTRA_DIST = \ pipeio2.awk \ pipeio2.in \ pipeio2.ok \ + pipeio3.awk \ + pipeio3.ok \ posix.awk \ posix.in \ posix.ok \ @@ -1189,8 +1191,8 @@ BASIC_TESTS = \ zero2 zeroe0 zeroflag UNIX_TESTS = \ - fflush getlnhd localenl pid pipeio1 pipeio2 poundbang rtlen rtlen01 \ - space strftlng + fflush getlnhd localenl pid pipeio1 pipeio2 pipeio3 poundbang \ + rtlen rtlen01 space strftlng GAWK_EXT_TESTS = \ aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \ @@ -3182,6 +3184,11 @@ getlnhd: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +pipeio3: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + aadelete1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index df272ce8..29f9a17c 100644 --- a/test/Maketests +++ b/test/Maketests @@ -907,6 +907,11 @@ getlnhd: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +pipeio3: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + aadelete1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/pipeio3.awk b/test/pipeio3.awk new file mode 100644 index 00000000..a1cd3743 --- /dev/null +++ b/test/pipeio3.awk @@ -0,0 +1,15 @@ +BEGIN { + outputCommand = "cart" + inputCommand = "ls" + + print "doing first print" > "/dev/stderr" + print "hello" | outputCommand + + print "doing first getline" > "/dev/stderr" + inputCommand | getline + + print "doing second print" > "/dev/stderr" + print "hello" | outputCommand + + print "made it here" > "/dev/stderr" +} diff --git a/test/pipeio3.ok b/test/pipeio3.ok new file mode 100644 index 00000000..17a08e9c --- /dev/null +++ b/test/pipeio3.ok @@ -0,0 +1,6 @@ +doing first print +doing first getline +sh: 1: cart: not found +doing second print +gawk: pipeio3.awk:12: fatal: print to "cart" failed (Broken pipe) +EXIT CODE: 2 |