Date: Tue, 14 Feb 2012 22:00:47 GMT From: Matthew Story <matthewstory@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: standards/165155: [PATCH][bin][standards] xargs does not print diagnostic information on utility termination via signal, or utility exit 255 Message-ID: <201202142200.q1EM0lDM074851@red.freebsd.org> Resent-Message-ID: <201202142210.q1EMA57P089398@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 165155 >Category: standards >Synopsis: [PATCH][bin][standards] xargs does not print diagnostic information on utility termination via signal, or utility exit 255 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Feb 14 22:10:05 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Matthew Story >Release: 9.0 >Organization: >Environment: FreeBSD matt9fromouterspace 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:15:25 UTC 2012 root@obrian.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386 >Description: Per POSIX (IEEE Std 1003.1-2008): 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. (via: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/xargs.html) FreeBSD xargs does exit without processing any remaining input if an invocation of utility terminates as a result of a signal, or if an invocation of utility exits with exit status 255, but it does not write a diagnostic message as required by the spec. >How-To-Repeat: $ jot - 1 10 | xargs -n1 sh -c 'kill $$' $ # note no output $ jot - 1 10 | xargs -n1 sh -c 'exit 255;' $ # note no output >Fix: apply patch, result is: $ jot - 1 10 | xargs -n1 sh -c 'kill $$' xargs: sh: terminated with signal 15, aborting $ jot - 1 10 | xargs -n1 sh -c 'exit 255' xargs: sh: exited with status 255, aborting Patch attached with submission follows: diff -u a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c --- a/usr.bin/xargs/xargs.c 2012-01-02 22:23:44.000000000 -0500 +++ b/usr.bin/xargs/xargs.c 2012-02-14 16:39:20.000000000 -0500 @@ -608,8 +608,11 @@ * If utility signaled or exited with a value of 255, * exit 1-125. */ - if (WIFSIGNALED(status) || WEXITSTATUS(status) == 255) - exit(1); + if (WIFSIGNALED(status)) + errx(1, "%s: terminated with signal %d, aborting", + name, WTERMSIG(status)); + if (WEXITSTATUS(status) == 255) + errx(1, "%s: exited with status 255, aborting", name); if (WEXITSTATUS(status)) rval = 1; } >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202142200.q1EM0lDM074851>