Subject: bin/2838: time does exit(0) when command crashes
To: None <gnats-bugs@gnats.netbsd.org>
From: Arne H. Juul <Arne.Juul@idt.ntnu.no>
List: netbsd-bugs
Date: 10/12/1996 20:14:25
>Number:         2838
>Category:       bin
>Synopsis:       time does exit(0) when command crashes
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 12 11:20:01 1996
>Last-Modified:
>Originator:     
>Organization:
	Norwegian University of Technology and Science
>Release:        1.2_BETA
>Environment:
	
System: NetBSD c231.idt.unit.no 1.2 NetBSD 1.2 (C231) #10: Mon Oct 7 19:17:26 MET DST 1996 root@c231.idt.unit.no:/usr/src/sys/arch/sparc/compile/C231 sparc


>Description:
	
	When the command run by time crashes, time exits with
	status 0.  This is bad in shell scripts.
>How-To-Repeat:
	
	time sh -c 'kill -2 $$' && echo wrong output
>Fix:
	
--- time.c.orig	Sat Oct 14 04:27:01 1995
+++ time.c	Sat Oct 12 20:08:35 1996
@@ -165,5 +165,5 @@
 			ru.ru_nivcsw, "involuntary context switches");
 	}
 
-	exit (WEXITSTATUS(status));
+	exit (WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE);
 }
>Audit-Trail:
>Unformatted: