From owner-freebsd-bugs Sat Oct 12 11:10:04 1996 Return-Path: owner-bugs Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id LAA16267 for bugs-outgoing; Sat, 12 Oct 1996 11:10:04 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id LAA16258; Sat, 12 Oct 1996 11:10:02 -0700 (PDT) Resent-Date: Sat, 12 Oct 1996 11:10:02 -0700 (PDT) Resent-Message-Id: <199610121810.LAA16258@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, Tor.Egge@idt.ntnu.no 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 ; 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 ; 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 Reply-To: Tor.Egge@idt.ntnu.no To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/1781: time returns with EXIT_SUCCESS on some failures Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >Number: 1781 >Category: bin >Synopsis: time returns with EXIT_SUCCESS on some failures >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Oct 12 11:10:01 PDT 1996 >Last-Modified: >Originator: Tor Egge >Organization: Norwegian University of Science and Technology, Trondheim, Norway >Release: FreeBSD 2.2-CURRENT i386 >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 #include #include + #include + #include #include #include *************** *** 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); } /* >Audit-Trail: >Unformatted: