From owner-freebsd-bugs Tue Feb 12 21:40:55 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 3424737B43E for ; Tue, 12 Feb 2002 21:40:29 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g1D5eRm01335; Tue, 12 Feb 2002 21:40:27 -0800 (PST) (envelope-from gnats) Received: from descent.robbins.dropbear.id.au (018.a.009.mel.iprimus.net.au [210.50.112.18]) by hub.freebsd.org (Postfix) with ESMTP id 8A07E37B402 for ; Tue, 12 Feb 2002 21:37:58 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g1D5bcd05187; Wed, 13 Feb 2002 16:37:38 +1100 (EST) (envelope-from tim) Message-Id: <200202130537.g1D5bcd05187@descent.robbins.dropbear.id.au> Date: Wed, 13 Feb 2002 16:37:38 +1100 (EST) From: Tim Robbins Reply-To: Tim Robbins To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/34898: [PATCH] rev 1.7 of xargs.c broke documented exit status Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 34898 >Category: bin >Synopsis: [PATCH] rev 1.7 of xargs.c broke documented exit status >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Feb 12 21:40:16 PST 2002 >Closed-Date: >Last-Modified: >Originator: Tim Robbins >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #3: Thu Feb 7 01:39:15 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386 >Description: Revision 1.7 of src/usr.bin/xargs/xargs.c, which changed the vfork() call to a fork(), broke the exit status 127 documented in xargs(1). It's broken in -STABLE and -CURRENT. >How-To-Repeat: tim@descent$ echo 'hi' | xargs /no xargs: /no: No such file or directory tim@descent$ echo $? 1 But xargs(1) says it should exit 127 instead of 1. >Fix: Index: xargs/xargs.c =================================================================== RCS file: /home/ncvs/src/usr.bin/xargs/xargs.c,v retrieving revision 1.11 diff -u -r1.11 xargs.c --- xargs/xargs.c 2001/12/11 22:36:26 1.11 +++ xargs/xargs.c 2002/02/13 05:32:54 @@ -296,7 +296,6 @@ run(argv) char **argv; { - volatile int noinvoke; char **p; pid_t pid; int status; @@ -308,21 +307,19 @@ (void)fprintf(stderr, "\n"); (void)fflush(stderr); } - noinvoke = 0; switch(pid = fork()) { case -1: err(1, "fork"); case 0: execvp(argv[0], argv); warn("%s", argv[0]); - noinvoke = 1; - _exit(1); + _exit(254); } pid = waitpid(pid, &status, 0); if (pid == -1) err(1, "waitpid"); /* If we couldn't invoke the utility, exit 127. */ - if (noinvoke) + if (WEXITSTATUS(status) == 254) exit(127); /* If utility signaled or exited with a value of 255, exit 1-125. */ if (WIFSIGNALED(status) || WEXITSTATUS(status) == 255) >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message