Permalink
Browse files

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

  • Loading branch information...
1 parent 789ec6d commit 97c6e61408b8a498cabfbb809a301df2af9d330b @jillest jillest committed Dec 8, 2012
Showing with 1 addition and 3 deletions.
  1. +1 −3 usr.bin/time/time.c
View
@@ -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 */

0 comments on commit 97c6e61

Please sign in to comment.