mirror of https://gitee.com/openkylin/libvirt.git
Ensure virExec preserves logging environment
The virFork call resets all logging handlers that may have been set. Re-enable them after fork in virExec, so that env variables fir LIBVIRT_LOG_OUTPUTS and LIBVIRT_LOG_FILTERS take effect until the execve() * src/util/util.c: Preserve logging in child in virExec
This commit is contained in:
parent
9288c31bf7
commit
882f78c3cb
|
@ -602,6 +602,9 @@ __virExec(const char *const*argv,
|
||||||
childout = -1;
|
childout = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Initialize full logging for a while */
|
||||||
|
virLogSetFromEnv();
|
||||||
|
|
||||||
/* Daemonize as late as possible, so the parent process can detect
|
/* Daemonize as late as possible, so the parent process can detect
|
||||||
* the above errors with wait* */
|
* the above errors with wait* */
|
||||||
if (flags & VIR_EXEC_DAEMON) {
|
if (flags & VIR_EXEC_DAEMON) {
|
||||||
|
@ -650,6 +653,9 @@ __virExec(const char *const*argv,
|
||||||
virClearCapabilities() < 0)
|
virClearCapabilities() < 0)
|
||||||
goto fork_error;
|
goto fork_error;
|
||||||
|
|
||||||
|
/* Close logging again to ensure no FDs leak to child */
|
||||||
|
virLogReset();
|
||||||
|
|
||||||
if (envp)
|
if (envp)
|
||||||
execve(argv[0], (char **) argv, (char**)envp);
|
execve(argv[0], (char **) argv, (char**)envp);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue