From owner-freebsd-bugs@FreeBSD.ORG Mon Nov 28 12:30:12 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6C4F116A41F for ; Mon, 28 Nov 2005 12:30:12 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id AF37E43D53 for ; Mon, 28 Nov 2005 12:30:11 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id jASCU82b005932 for ; Mon, 28 Nov 2005 12:30:08 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id jASCU8XN005931; Mon, 28 Nov 2005 12:30:08 GMT (envelope-from gnats) Resent-Date: Mon, 28 Nov 2005 12:30:08 GMT Resent-Message-Id: <200511281230.jASCU8XN005931@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Arne H Juul Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 85A9516A41F for ; Mon, 28 Nov 2005 12:29:02 +0000 (GMT) (envelope-from arnej@dhcp-247.trondheim.corp.yahoo.com) Received: from dhcp-247.trondheim.corp.yahoo.com (pat-gw.trondheim.corp.yahoo.com [217.144.236.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id D628643D4C for ; Mon, 28 Nov 2005 12:29:01 +0000 (GMT) (envelope-from arnej@dhcp-247.trondheim.corp.yahoo.com) Received: from dhcp-247.trondheim.corp.yahoo.com (localhost [127.0.0.1]) by dhcp-247.trondheim.corp.yahoo.com (8.13.4/8.13.3) with ESMTP id jASCT6OM015304; Mon, 28 Nov 2005 13:29:06 +0100 (CET) (envelope-from arnej@dhcp-247.trondheim.corp.yahoo.com) Received: (from arnej@localhost) by dhcp-247.trondheim.corp.yahoo.com (8.13.4/8.13.3/Submit) id jASCT6k4015303; Mon, 28 Nov 2005 13:29:06 +0100 (CET) (envelope-from arnej) Message-Id: <200511281229.jASCT6k4015303@dhcp-247.trondheim.corp.yahoo.com> Date: Mon, 28 Nov 2005 13:29:06 +0100 (CET) From: Arne H Juul To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: arnej@pvv.ntnu.no Subject: bin/89666: /usr/bin/time leaves extra file open X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Arne H Juul List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Nov 2005 12:30:12 -0000 >Number: 89666 >Category: bin >Synopsis: /usr/bin/time leaves extra file open >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: Mon Nov 28 12:30:08 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Arne H Juul >Release: FreeBSD 6.0-STABLE amd64 >Organization: Yahoo! >Environment: System: FreeBSD dhcp-247.trondheim.corp.yahoo.com 6.0-STABLE FreeBSD 6.0-STABLE #0: Wed Nov 23 15:08:57 CET 2005 arnej@dhcp-247.trondheim.corp.yahoo.com:/usr/obj/usr/src.6/sys/GENERIC amd64 This bug is in /usr/bin/time from at least FreeBSD 4.x, where I originally found it. Probably it's even older. >Description: When using the -o option to /usr/bin/time to get the timing information in its own file, the file is left open while running the child process; this isn't usually a problem but can cause hard-to-find problems in some cases. In my case a script timed the startup of a server with -o /dev/stdout, which made sshd hang waiting for the server to close the file descriptor it didn't know about afterwards. >How-To-Repeat: /usr/bin/time -o /tmp/time.output sh -c 'echo foo >&3' cat /tmp/time.output >Fix: Index: time.c =================================================================== RCS file: /usr/cvs/src/usr.bin/time/time.c,v retrieving revision 1.27 diff -u -r1.27 time.c --- time.c 21 May 2005 09:55:08 -0000 1.27 +++ time.c 28 Nov 2005 12:15:03 -0000 @@ -121,6 +121,7 @@ err(1, "time"); /* NOTREACHED */ case 0: /* child */ + if (out != stderr) fclose(out); execvp(*argv, argv); err(errno == ENOENT ? 127 : 126, "%s", *argv); /* NOTREACHED */ >Release-Note: >Audit-Trail: >Unformatted: