Blame SOURCES/0507-core-execute-fix-fork-fail-handling-in-exec_spawn.patch

17b0f1
From 03118775f6a9bf505a65dd0b86a6d2de2e3493a3 Mon Sep 17 00:00:00 2001
17b0f1
From: lc85446 <lc85446@alibaba-inc.com>
17b0f1
Date: Thu, 26 Nov 2015 11:46:40 +0800
17b0f1
Subject: [PATCH] core:execute: fix fork() fail handling in exec_spawn()
17b0f1
17b0f1
If pid < 0 after fork(), 0 is always returned because r =
17b0f1
exec_context_load_environment() has exited successfully.
17b0f1
17b0f1
This will make the caller of exec_spawn() not able to handle
17b0f1
the fork() error case and make systemd abort assert() possibly.
17b0f1
17b0f1
Cherry-picked from: 74129a127676e4f0edac0db4296c103e76ec6694
17b0f1
Resolves: #1437114
17b0f1
---
17b0f1
 src/core/execute.c | 2 +-
17b0f1
 1 file changed, 1 insertion(+), 1 deletion(-)
17b0f1
17b0f1
diff --git a/src/core/execute.c b/src/core/execute.c
17b0f1
index 4265b9c348..e68276973b 100644
17b0f1
--- a/src/core/execute.c
17b0f1
+++ b/src/core/execute.c
17b0f1
@@ -1977,7 +1977,7 @@ int exec_spawn(ExecCommand *command,
17b0f1
                         NULL);
17b0f1
         pid = fork();
17b0f1
         if (pid < 0)
17b0f1
-                return log_unit_error_errno(params->unit_id, r, "Failed to fork: %m");
17b0f1
+                return log_unit_error_errno(params->unit_id, errno, "Failed to fork: %m");
17b0f1
 
17b0f1
         if (pid == 0) {
17b0f1
                 int exit_status;