提交 a87e4788 编写于 作者: R Rafael Fonseca 提交者: Ján Tomko

util: virdaemon: fix waiting for child processes

Unlike `waitpid`, `virProcessWait` only returns -1 (error) or 0
(success), so comparing that to `pid` will always be false and the
parent will report failure with:

error : main:851 : Failed to fork as daemon: No such file or directory

even though the grandchild process is succesfully running. Note that the
errno message is misleading: it was last set when trying to find a
restart state file.
Signed-off-by: NRafael Fonseca <r4f4rfs@gmail.com>
Reported-by: NMarcin Krol <hawk@tld-linux.org>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NJán Tomko <jtomko@redhat.com>
上级 4df7280b
......@@ -97,15 +97,14 @@ virDaemonForkIntoBackground(const char *argv0)
default:
{
/* parent */
int got, exitstatus = 0;
int exitstatus = 0;
int ret;
char status;
VIR_FORCE_CLOSE(statuspipe[1]);
/* We wait to make sure the first child forked successfully */
if ((got = virProcessWait(pid, &exitstatus, 0)) < 0 ||
got != pid ||
if (virProcessWait(pid, &exitstatus, 0) < 0 ||
exitstatus != 0) {
goto error;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册