From Tor.Egge@idt.ntnu.no  Sat Oct 12 11:07:42 1996
Received: from pat.idt.unit.no (pat.idt.unit.no [129.241.103.5])
          by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id LAA15980
          for <FreeBSD-gnats-submit@freebsd.org>; Sat, 12 Oct 1996 11:07:31 -0700 (PDT)
Received: from ikke.idt.unit.no (ikke.idt.unit.no [129.241.111.65]) by pat.idt.unit.no (8.7.5/8.7.3) with ESMTP id UAA20374 for <FreeBSD-gnats-submit@freebsd.org>; Sat, 12 Oct 1996 20:07:07 +0200 (MET DST)
Received: (from tegge@localhost) by ikke.idt.unit.no (8.7.6/8.7.3) id UAA08645; Sat, 12 Oct 1996 20:07:06 +0200 (MET DST)
Message-Id: <199610121807.UAA08645@ikke.idt.unit.no>
Date: Sat, 12 Oct 1996 20:07:06 +0200 (MET DST)
From: Tor Egge <Tor.Egge@idt.ntnu.no>
Reply-To: Tor.Egge@idt.ntnu.no
To: FreeBSD-gnats-submit@freebsd.org
Subject: time returns with EXIT_SUCCESS on some failures
X-Send-Pr-Version: 3.2

>Number:         1781
>Category:       bin
>Synopsis:       time returns with EXIT_SUCCESS on some failures
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct 12 11:10:01 PDT 1996
>Closed-Date:    Sat Oct 12 11:41:43 PDT 1996
>Last-Modified:  Sat Oct 12 11:41:58 PDT 1996
>Originator:     Tor Egge
>Release:        FreeBSD 2.2-CURRENT i386
>Organization:
Norwegian University of Science and Technology, Trondheim, Norway

>Environment:

FreeBSD ikke.idt.unit.no 2.2-CURRENT FreeBSD 2.2-CURRENT #2: Tue Oct  8 19:39:21 MET DST 1996     root@ikke.idt.unit.no:/usr/src/sys/compile/TEGGE  i386

>Description:

	The time command does not check for normal exit of the 
	program being timed when determining what exit code to return.

>How-To-Repeat:

	Make a short program that fails, e.g. 'main() { abort(); }'
	
	run time on that program and check exit status.

>Fix:
Index: time.c
===================================================================
RCS file: /export/akg1/cvs/src/usr.bin/time/time.c,v
retrieving revision 1.3
diff -c -r1.3 time.c
*** time.c	1996/07/30 19:00:12	1.3
--- time.c	1996/10/12 17:59:37
***************
*** 46,51 ****
--- 46,53 ----
  #include <sys/resource.h>
  #include <sys/signal.h>
  #include <sys/sysctl.h>
+ #include <stdlib.h>
+ #include <sys/wait.h>
  
  #include <err.h>
  #include <stdio.h>
***************
*** 149,155 ****
  		fprintf(stderr, "%10ld  %s\n",
  			ru.ru_nivcsw, "involuntary context switches");
  	}
! 	exit (status>>8);
  }
  
  /*
--- 151,157 ----
  		fprintf(stderr, "%10ld  %s\n",
  			ru.ru_nivcsw, "involuntary context switches");
  	}
! 	exit (WIFEXITED(status)?WEXITSTATUS(status):EXIT_FAILURE);
  }
  
  /*
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: jkh 
State-Changed-When: Sat Oct 12 11:41:43 PDT 1996 
State-Changed-Why:  
The fix appears to be correct - applied, thanks! 
>Unformatted:
