Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Feb 2002 16:37:38 +1100 (EST)
From:      Tim Robbins <tim@robbins.dropbear.id.au>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/34898: [PATCH] rev 1.7 of xargs.c broke documented exit status
Message-ID:  <200202130537.g1D5bcd05187@descent.robbins.dropbear.id.au>

next in thread | raw e-mail | index | archive | help

>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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200202130537.g1D5bcd05187>