Blame SOURCES/time-1.9-Close-outfp-before-exec.patch

27f975
From 6a5c4499aab677d19157c7adcf598d14267283c1 Mon Sep 17 00:00:00 2001
27f975
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
27f975
Date: Mon, 16 Nov 2020 17:45:04 +0100
27f975
Subject: [PATCH] Close outfp before exec
27f975
MIME-Version: 1.0
27f975
Content-Type: text/plain; charset=UTF-8
27f975
Content-Transfer-Encoding: 8bit
27f975
27f975
When called with --outfile, we open an output file to which
27f975
we log timing results. Close that descriptor in the child
27f975
fork before exec'ing the process to be timed.
27f975
27f975
Reported-by: Ed Santiago <santiago@redhat.com>
27f975
Signed-off-by: Petr Písař <ppisar@redhat.com>
27f975
---
27f975
 src/time.c | 2 ++
27f975
 1 file changed, 2 insertions(+)
27f975
27f975
diff --git a/src/time.c b/src/time.c
27f975
index f76265a..2f2b702 100644
27f975
--- a/src/time.c
27f975
+++ b/src/time.c
27f975
@@ -738,6 +738,8 @@ run_command (cmd, resp)
27f975
     error (EXIT_CANCELED, errno, "cannot fork");
27f975
   else if (pid == 0)
27f975
     {				/* If child.  */
27f975
+      if (outfp != stderr)
27f975
+        fclose(outfp);
27f975
       /* Don't cast execvp arguments; that causes errors on some systems,
27f975
 	 versus merely warnings if the cast is left off.  */
27f975
       execvp (cmd[0], cmd);
27f975
-- 
27f975
2.25.4
27f975