Re: [PATCH 2/3] command: avoid double close

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2011/6/14 Eric Blake <eblake@xxxxxxxxxx>:
> 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]