diff options
author | Eric Blake <eblake@redhat.com> | 2011-07-12 14:56:03 -0600 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2011-07-21 10:34:51 -0600 |
commit | 5d804ffae4ca493c70b8fadd697ec2d822876ec4 (patch) | |
tree | 8f4831de0df3d7964a38151091be0efdbca4ed15 /src/util/iohelper.c | |
parent | 4289114518c775a1ff2ec012c597bbf02a80ecbb (diff) | |
download | libvirt-5d804ffae4ca493c70b8fadd697ec2d822876ec4.tar.gz |
command: avoid leaking fds across fork
Since libvirt is multi-threaded, we should use FD_CLOEXEC as much
as possible in the parent, and only relax fds to inherited after
forking, to avoid leaking an fd created in one thread to a fork
run in another thread. This gets us closer to that ideal, by
making virCommand automatically clear FD_CLOEXEC on fds intended
for the child, as well as avoiding a window of time with non-cloexec
pipes created for capturing output.
* src/util/command.c (virExecWithHook): Use CLOEXEC in parent. In
child, guarantee that all fds to pass to child are inheritable.
(getDevNull): Use CLOEXEC.
(prepareStdFd): New helper function.
(virCommandRun, virCommandRequireHandshake): Use pipe2.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Simplify caller.
Diffstat (limited to 'src/util/iohelper.c')
0 files changed, 0 insertions, 0 deletions