summaryrefslogtreecommitdiff
path: root/compatfd.c
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2008-10-30 17:51:49 +0000
committerAvi Kivity <avi@redhat.com>2008-11-02 11:57:02 +0200
commitbaa32a99189b35897bf36a2107987a7331bfeaee (patch)
tree3965db464412e4eb7ca86ba2066349be0c2b6cc0 /compatfd.c
parent7be94fba54cfd5ad8c2057ce3471011953850612 (diff)
Dup the qemu_eventfd() return
qemu_eventfd() returns two file descriptors, both of which must be closed when pipe() is used in the absence of eventfd(). Duplicate the eventfd() file descriptor so that closing both descriptors will work in that case. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'compatfd.c')
-rw-r--r--compatfd.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/compatfd.c b/compatfd.c
index cc5ced396..36e37e5d1 100644
--- a/compatfd.c
+++ b/compatfd.c
@@ -118,7 +118,11 @@ int qemu_eventfd(int *fds)
ret = syscall(SYS_eventfd, 0);
if (ret >= 0) {
- fds[0] = fds[1] = ret;
+ fds[0] = ret;
+ if ((fds[1] = dup(ret)) == -1) {
+ close(ret);
+ return -1;
+ }
return 0;
}
#endif