standards/165155: [PATCH][bin][standards] xargs does not print
diagnostic information on utility termination via signal,
or utility exit 255
Matthew Story
matthewstory at gmail.com
Tue Feb 14 22:10:06 UTC 2012
>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 at 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:
More information about the freebsd-standards
mailing list