]> xenbits.xensource.com Git - libvirt.git/commit
virCommand: use procfs to learn opened FDs
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 2 Jul 2019 17:49:51 +0000 (19:49 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 16 Jul 2019 11:47:49 +0000 (13:47 +0200)
commit432faf259b696043ee5d7e8f657d855419a9a3fa
tree6d8c61cbb7fdd8916305ca8d31e4f74f42209686
parentc1a9bfbbba48fea44fdfbe532e084c5323c9c9b3
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 <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/vircommand.c