[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SIGPIPE warning
From: |
James Youngman |
Subject: |
Re: SIGPIPE warning |
Date: |
Sat, 20 Apr 2013 14:59:01 +0100 |
On Fri, Mar 9, 2012 at 10:41 PM, Pádraig Brady <address@hidden> wrote:
>
> I noticed xargs output a warning about SIGPIPE
>
> $ yes 1234 | xargs -n1 | head -n1
> 1234
> xargs: /bin/echo: terminated by signal 13
>
> That's not normally the case on the shell:
>
> $ yes 1234 | head -n1
> 1234
>
> Nor in other process management utils:
>
> $ timeout 1 yes 1234 | head -n1
> 1234
>
> Could we supress that warning?
> At least for SIGPIPE?
Hmm, POSIX (http://pubs.opengroup.org/onlinepubs/009695399/utilities/xargs.html)
seems to require it:
CONSEQUENCES OF ERRORS
If a command line meeting the specified requirements cannot be
assembled, the utility cannot be invoked, an invocation of the utility
is terminated by a signal, or an invocation of the utility exits with
exit status 255, the xargs utility shall write a diagnostic message
and exit without processing any remaining input.
In this case the utility (echo) is indeed being terminated by a
signal. But IMO the report that echo was killed by a signal isn't
helpful to the user in this case. I think that "yes" gets away with
this since it is not standardised by POSIX.
If you can think of a way for xargs still to be POSIX-compliant while
suppressing the message, that would probably be a good choice. Any
ideas?
James.
- Re: SIGPIPE warning,
James Youngman <=