[systemd-devel] wrong return value when fork() fail in exec_spawn() ?
Lennart Poettering
lennart at poettering.net
Fri Nov 27 05:18:08 PST 2015
On Thu, 26.11.15 12:27, eshark (eshark77 at 163.com) wrote:
>
> Hi, all,
>
> It seems that the exec_spawn() will return 0 if fork() fails, because that
> return log_unit_error_errno(params->unit_id, errno, "Failed to fork: %m");
> will return -r eventually. And here r = exec_context_load_environment() , which has
> exited successfully.
>
> This may lead big trouble to the caller of exec_spawn(). For example, mount_spawn(), which
> also calls exec_spawn(), will not goto fail but run continuelly in this case. Then the following unit_watch_pid()
> will fail at assert(pid >= 1);.
>
> I also commit a patch to fix this problem, please help to review.
Indeed, this is a bug! Patch looks great! I turned this now into a
github PR (https://github.com/systemd/systemd/pull/2048), because
that's how we prefer submissions these days. Will merge as soon as the
CI likes it too.
Thanks a lot!
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list