>From 95b6dd923e176f0c42646e64cc9f22fb67a12b8f Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Fri, 6 Nov 2020 20:06:24 -0700 Subject: [PATCH] Close outfp before exec When called with --outfile, we open an output file to which we log timing results. Close that descriptor in the child fork before exec'ing the process to be timed. Signed-off-by: Ed Santiago --- src/time.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/time.c b/src/time.c index 53904c9..9c7d287 100644 --- a/src/time.c +++ b/src/time.c @@ -813,6 +813,8 @@ run_command (cmd, resp) error (EXIT_CANCELED, errno, "cannot fork"); else if (pid == 0) { /* If child. */ + if (outfp != NULL) + fclose(outfp); /* Don't cast execvp arguments; that causes errors on some systems, versus merely warnings if the cast is left off. */ execvp (cmd[0], cmd); -- 2.26.2