Date: Sat, 12 Oct 1996 20:07:06 +0200 (MET DST) From: Tor Egge <Tor.Egge@idt.ntnu.no> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/1781: time returns with EXIT_SUCCESS on some failures Message-ID: <199610121807.UAA08645@ikke.idt.unit.no> Resent-Message-ID: <199610121810.LAA16258@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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 <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);
}
/*
>Audit-Trail:
>Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610121807.UAA08645>
