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

This commit is contained in:
Jilles Tjoelker 2012-12-08 17:41:39 +00:00
parent cca6f4a8f3
commit 689f0bd93b

View File

@ -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 */