Blame SOURCES/0267-cli-run-command-Replace-use-of-vfork-with-fork.patch

b12e4c
From c8ef6fff3b051ef970a439115e1630105f87bdce Mon Sep 17 00:00:00 2001
b12e4c
From: Ernestas Kulik <ekulik@redhat.com>
b12e4c
Date: Mon, 10 Jun 2019 13:38:34 +0200
b12e4c
Subject: [PATCH] cli: run-command: Replace use of vfork() with fork()
b12e4c
b12e4c
vfork() replacing fork() was most likely an optimization, but, over
b12e4c
time, changes were added that violate the contract, i.e. the code
b12e4c
started going things other than exec and exit:
b12e4c
https://pubs.opengroup.org/onlinepubs/009695399/functions/vfork.html.
b12e4c
b12e4c
posix_spawn(), as recommended by Clang, would not be a suitable
b12e4c
replacement, as we need to call tcsetpgrp() on the child, doing which
b12e4c
after exec is too late if the goal is to avoid races.
b12e4c
b12e4c
Signed-off-by: Ernestas Kulik <ekulik@redhat.com>
b12e4c
---
b12e4c
 src/cli/run-command.c | 6 +++---
b12e4c
 1 file changed, 3 insertions(+), 3 deletions(-)
b12e4c
b12e4c
diff --git a/src/cli/run-command.c b/src/cli/run-command.c
b12e4c
index 232f725..a8416a0 100644
b12e4c
--- a/src/cli/run-command.c
b12e4c
+++ b/src/cli/run-command.c
b12e4c
@@ -53,10 +53,10 @@ static void start_command(struct command *cmd)
b12e4c
 
b12e4c
   fflush(NULL);
b12e4c
 
b12e4c
-  cmd->pid = vfork();
b12e4c
+  cmd->pid = fork();
b12e4c
   if (cmd->pid < 0)
b12e4c
   {
b12e4c
-    perror_msg_and_die("vfork");
b12e4c
+    perror_msg_and_die("fork");
b12e4c
   }
b12e4c
   if (cmd->pid == 0)
b12e4c
   {
b12e4c
@@ -85,7 +85,7 @@ static void start_command(struct command *cmd)
b12e4c
     signal(SIGTTOU, SIG_DFL);
b12e4c
 
b12e4c
     execvp(cmd->argv[0], cmd->argv);
b12e4c
-    /* Better to use _exit (not exit) after vfork:
b12e4c
+    /* Better to use _exit (not exit) after fork:
b12e4c
      * we don't want to mess up parent's memory state
b12e4c
      * by running libc cleanup routines.
b12e4c
      */
b12e4c
-- 
b12e4c
2.21.0
b12e4c