From 23583c4fe122ebaebadb95162edd18a40d5eb963 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Fri, 24 Feb 2012 12:35:17 +0000 Subject: [PATCH] xargs: If a utility exits with 255 or a signal, write an error message. If a utility called by xargs exits with status 255 or because of a signal, POSIX requires writing an error message. PR: 165155 Submitted by: Matthew Story matthewstory gmail com --- usr.bin/xargs/xargs.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c index 09548002f89..35d07c73143 100644 --- a/usr.bin/xargs/xargs.c +++ b/usr.bin/xargs/xargs.c @@ -281,7 +281,7 @@ parse_input(int argc, char *argv[]) case EOF: /* No arguments since last exec. */ if (p == bbp) { - waitchildren(*argv, 1); + waitchildren(*av, 1); exit(rval); } goto arg1; @@ -368,7 +368,7 @@ arg2: } prerun(argc, av); if (ch == EOF || foundeof) { - waitchildren(*argv, 1); + waitchildren(*av, 1); exit(rval); } p = bbp; @@ -608,8 +608,11 @@ waitchildren(const char *name, int waitall) * 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; }