virCommand: use procfs to learn opened FDs
virCommand: use procfs to learn opened FDs

When spawning a child process, between fork() and exec() we close
all file descriptors and keep only those the caller wants us to
pass onto the child. The problem is how we do that. Currently, we
get the limit of opened files and then iterate through each one
of them and either close() it or make it survive exec(). This
approach is suboptimal (although, not that much in default
configurations where the limit is pretty low - 1024). We have
/proc where we can learn what FDs we hold open and thus we can
selectively close only those.

Signed-off-by: Michal Privoznik <83d82aaba2eed257f4814b0c239c260c4caaadf0@redhat.com>
Reviewed-by: Ján Tomko <4cab11cfb98d3c937327354a78eb07dbb6ee2bc6@redhat.com>

nertpinx/libvirt,jardasgit/libvirt,libvirt/libvirt,jfehlig/libvirt,nertpinx/libvirt,andreabolognani/libvirt,crobinso/libvirt,jfehlig/libvirt,libvirt/libvirt,libvirt/libvirt,crobinso/libvirt,andreabolognani/libvirt,nertpinx/libvirt,andreabolognani/libvirt,crobinso/libvirt,fabianfreyer/libvirt,fabianfreyer/libvirt,zippy2/libvirt,andreabolognani/libvirt,nertpinx/libvirt,olafhering/libvirt,olafhering/libvirt,olafhering/libvirt,nertpinx/libvirt,eskultety/libvirt,fabianfreyer/libvirt,jfehlig/libvirt,eskultety/libvirt,zippy2/libvirt,jardasgit/libvirt,eskultety/libvirt,zippy2/libvirt,fabianfreyer/libvirt,jardasgit/libvirt,zippy2/libvirt,jardasgit/libvirt,andreabolognani/libvirt,crobinso/libvirt,libvirt/libvirt,jardasgit/libvirt,olafhering/libvirt,jfehlig/libvirt,eskultety/libvirt,fabianfreyer/libvirt,eskultety/libvirt