bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ignored SIGPIPE (Darwin vs. cat)


From: Bruno Haible
Subject: Re: ignored SIGPIPE (Darwin vs. cat)
Date: Wed, 4 Mar 2009 12:38:40 +0100
User-agent: KMail/1.9.9

Eric Blake wrote:
> you can often write 
> tests in such a way that you can guarantee the reader will consume all
> input until the writer has completed, rather than completing early, to
> avoid the issue of whether SIGPIPE is ignored.

I want to avoid the extra effort to inspect all unit tests one by one. We have
23 unit tests that use shell pipes in gnulib alone, more in m4, gettext, etc.

Additionally, the issue with SIGPIPE is so involved that it takes years of Unix
experience to understand it. We cannot expect that every contributor of a
gnulib unit test understands this issue, and I don't want to spent my brain
cycles when reviewing contributions on this particular issue.

Therefore, what is an simple coding idiom that will get rid of these kinds of
error messages, without decreasing the reliability and debuggability of our
tests?

> > I would prefer to add a
> > catch-all clause to the beginning of all tests which use pipes:
> >
> >   #!/bin/sh
> >   if trap | grep "^trap -- ['\"]['\"] SIGPIPE\$" > /dev/null; then
> >     echo "Skipping test: SIGPIPE is ignored"
> >     exit 77
> >   fi
> 
> That won't necessarily help - a shell that inherits an ignored SIGPIPE,
> rather than having an explicitly user-ignored situation, is under no
> obligation to report that fact during 'trap -p'.

OK, How about this test instead, then?

  if expr `( { sleep 1; yes | head -n 10000; echo $? 1>&3; } | :) 2>/dev/null 
3>&1` '<' 128 > /dev/null; then
    echo "Skipping test: SIGPIPE is ignored"
    exit 77
  fi

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]