From: lc85446 Date: Thu, 26 Nov 2015 03:46:40 +0000 (+0800) Subject: core:execute: fix fork() fail handling in exec_spawn() X-Git-Tag: v229~252^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2048%2Fhead;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/core/execute.c b/src/core/execute.c index 677480cbe1f..4f67a9de83c 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -2056,7 +2056,7 @@ int exec_spawn(Unit *unit, NULL); pid = fork(); if (pid < 0) - return log_unit_error_errno(unit, r, "Failed to fork: %m"); + return log_unit_error_errno(unit, errno, "Failed to fork: %m"); if (pid == 0) { int exit_status;