Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Dec 2012 17:41:39 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r244034 - head/usr.bin/time
Message-ID:  <201212081741.qB8HfdQJ086118@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Sat Dec  8 17:41:39 2012
New Revision: 244034
URL: http://svnweb.freebsd.org/changeset/base/244034

Log:
  time: Use close-on-exec instead of fclose() in the child process.

Modified:
  head/usr.bin/time/time.c

Modified: head/usr.bin/time/time.c
==============================================================================
--- head/usr.bin/time/time.c	Sat Dec  8 15:11:09 2012	(r244033)
+++ head/usr.bin/time/time.c	Sat Dec  8 17:41:39 2012	(r244034)
@@ -112,7 +112,7 @@ main(int argc, char **argv)
 	argv += optind;
 
 	if (ofn) {
-	        if ((out = fopen(ofn, aflag ? "a" : "w")) == NULL)
+	        if ((out = fopen(ofn, aflag ? "ae" : "we")) == NULL)
 		        err(1, "%s", ofn);
 		setvbuf(out, (char *)NULL, _IONBF, (size_t)0);
 	}
@@ -123,8 +123,6 @@ main(int argc, char **argv)
 		err(1, "time");
 		/* NOTREACHED */
 	case 0:				/* child */
-		if (ofn)
-			fclose(out);
 		execvp(*argv, argv);
 		err(errno == ENOENT ? 127 : 126, "%s", *argv);
 		/* NOTREACHED */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212081741.qB8HfdQJ086118>