Date: Mon, 28 Nov 2005 13:29:06 +0100 (CET) From: Arne H Juul <Arne.Juul@europe.yahoo-inc.com> To: FreeBSD-gnats-submit@FreeBSD.org Cc: arnej@pvv.ntnu.no Subject: bin/89666: /usr/bin/time leaves extra file open Message-ID: <200511281229.jASCT6k4015303@dhcp-247.trondheim.corp.yahoo.com> Resent-Message-ID: <200511281230.jASCU8XN005931@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200511281229.jASCT6k4015303>