]> Savannah Git Hosting - gnulib.git/commitdiff
maint.mk: less syntax-check noise when SIGPIPE is ignored
authorEric Blake <eblake@redhat.com>
Tue, 8 Jul 2014 19:12:28 +0000 (13:12 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 8 Jul 2014 19:54:26 +0000 (13:54 -0600)
For a project with enough files, such as libvirt, vc-list-files
can produce so much input that it can lead to SIGPIPE to earlier
parts of a pipeline when later parts do a quick filter.  Also,
many buildbot environments (annoyingly) ignore SIGPIPE, which
causes a number of tools to be rather chatty about reporting
EPIPE write failures.  It doesn't help that POSIX has standardized
that the shell is unable to revert SIGPIPE to unignored status
if it inherits it as ignored - otherwise, the solution would just
be to re-enable SIGPIPE anywhere we expect to benefit from early
filtering exits.  Here's a short demonstration:

$ ( trap '' PIPE; build-aux/vc-list-files | grep -l '\.c$' >/dev/null)
sed: couldn't write 16 items to stdout: Broken pipe

and a link to the much larger buildbot results against libvirt:
http://honk.sigxcpu.org:8001/job/libvirt-syntax-check/2465/console
with noise such as this, detracting from the later actual build
failure it was reporting:

> prohibit_argmatch_without_use
> grep: write error
> grep: write error
> /bin/sed: couldn't write 25 items to stdout: Broken pipe
> sed: couldn't write 1 item to stdout: Broken pipe
> 0.46 prohibit_argmatch_without_use

But look at the above example: we are piping data to grep -l,
and then discarding that output.  At most, data | grep -l will
output "(standard input)", and exit early if the first match
is found before the end of a page (causing SIGPIPE to the process
feeding the pipe).  It makes much more sense to use grep -l when
searching for a subset of files that have a match among a larger
set of file names passed as arguments, and NOT when used to
filter stdin.  Sure, we're burning a bit more CPU power by
processing the full list instead of exiting early, but at least
it cuts down on the noise.

* top/maint.mk (_sc_header_without_use)
(sc_require_config_h_first): Parse full list.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
top/maint.mk

index 81e800f5f38338700a6359f49f834cc4a9b0e101..40cf11d6fb72d35102becad6befbdfe0d2337570 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-07-08  Eric Blake  <eblake@redhat.com>
+
+       maint.mk: less syntax-check noise when SIGPIPE is ignored
+       * top/maint.mk (_sc_header_without_use)
+       (sc_require_config_h_first): Parse full list.
+
 2014-07-07  Eli Zaretskii  <eliz@gnu.org>
            Paul Eggert  <eggert@cs.ucla.edu>
 
index 3f369b7161d118fc3a3f2a56760cc409f1cf292c..0cc769c535035126624db2c18b7c301b96ef1552 100644 (file)
@@ -440,7 +440,7 @@ sc_require_config_h:
 # You must include <config.h> before including any other header file.
 # This can possibly be via a package-specific header, if given by cfg.mk.
 sc_require_config_h_first:
-       @if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then       \
+       @if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then          \
          fail=0;                                                       \
          for i in $$($(VC_LIST_EXCEPT) | grep '\.c$$'); do             \
            grep '^# *include\>' $$i | $(SED) 1q                        \
@@ -464,7 +464,7 @@ sc_prohibit_HAVE_MBRTOWC:
 define _sc_header_without_use
   dummy=; : so we do not need a semicolon before each use;             \
   h_esc=`echo '[<"]'"$$h"'[">]'|$(SED) 's/\./\\\\./g'`;                        \
-  if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then             \
+  if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then                        \
     files=$$(grep -l '^# *include '"$$h_esc"                           \
             $$($(VC_LIST_EXCEPT) | grep '\.c$$')) &&                   \
     grep -LE "$$re" $$files | grep . &&                                        \