You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

30 lines
1.1 KiB

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