mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
command: avoid double close in virExecWithHook
Fix possible double close in the child process after the fork in case infd and outfd are equal, just like they are after being called from virNetSocketNewConnectCommand.
This commit is contained in:
parent
4efde75fab
commit
8211c677a3
@ -547,17 +547,13 @@ virExecWithHook(const char *const*argv,
|
||||
goto fork_error;
|
||||
}
|
||||
|
||||
if (infd != STDIN_FILENO && infd != null)
|
||||
if (infd != STDIN_FILENO && infd != null && infd != childerr &&
|
||||
infd != childout)
|
||||
VIR_FORCE_CLOSE(infd);
|
||||
if (childout > STDERR_FILENO && childout != null) {
|
||||
tmpfd = childout; /* preserve childout value */
|
||||
VIR_FORCE_CLOSE(tmpfd);
|
||||
}
|
||||
if (childerr > STDERR_FILENO &&
|
||||
childerr != childout &&
|
||||
childerr != null) {
|
||||
if (childout > STDERR_FILENO && childout != null && childout != childerr)
|
||||
VIR_FORCE_CLOSE(childout);
|
||||
if (childerr > STDERR_FILENO && childerr != null)
|
||||
VIR_FORCE_CLOSE(childerr);
|
||||
}
|
||||
VIR_FORCE_CLOSE(null);
|
||||
|
||||
/* Initialize full logging for a while */
|
||||
|
Loading…
Reference in New Issue
Block a user