[libvirt] [PATCH 2/3] command: avoid double close
Matthias Bolte
matthias.bolte at googlemail.com
Tue Jun 14 10:05:10 UTC 2011
2011/6/14 Eric Blake <eblake at redhat.com>:
> Previously, the parent process opened 'null' to /dev/null, then
> the child process closes 'null' as well as 'childout'. But if
> childout was set to be null, then this is a double close. At
> least the double close was confined to the child process after a
> fork, and therefore there is no risk of another thread opening
> an fd of the same value to be bitten by the double close, but it
> is always better to avoid double-close to begin with.
>
> Additionally, if all three fds were specified, then opening
> 'null' was wasted.
>
> This patch fixes things to lazily open null on the first use,
> then guarantees it gets closed exactly once.
>
> * src/util/command.c (getDevNull): New helper function.
> (virExecWithHook): Use it to avoid spurious opens and double close.
> ---
> src/util/command.c | 44 ++++++++++++++++++++++++++++++++------------
> 1 files changed, 32 insertions(+), 12 deletions(-)
>
ACK.
--
Matthias Bolte
http://photron.blogspot.com
More information about the libvir-list
mailing list