From 8ae5df5d93ca6d059d944f64416893f023e59c0d Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake@redhat.com>
Date: Wed, 6 Apr 2011 08:10:28 -0600
Subject: [PATCH] virsh: fix mingw startup

* .gnulib: Update to latest, for pipe2.
* bootstrap.conf (gnulib_modules): Add pipe2.
* src/util/event_poll.c (virEventPollInit): Use it, to avoid
problematic virSetCloseExec on mingw.
---
 .gnulib               | 2 +-
 bootstrap.conf        | 1 +
 src/util/event_poll.c | 7 ++-----
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/.gnulib b/.gnulib
index f796520035..bd5d1e6211 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit f79652003534e496bca1e49922ca521f12ca8051
+Subproject commit bd5d1e621103ea3f7fbae09010348ce2df563808
diff --git a/bootstrap.conf b/bootstrap.conf
index 11d2199c99..3db0c6373a 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -54,6 +54,7 @@ nonblocking
 perror
 physmem
 pipe-posix
+pipe2
 poll
 posix-shell
 pthread
diff --git a/src/util/event_poll.c b/src/util/event_poll.c
index 91000e29ab..cd1ff4a0f9 100644
--- a/src/util/event_poll.c
+++ b/src/util/event_poll.c
@@ -29,6 +29,7 @@
 #include <sys/time.h>
 #include <errno.h>
 #include <unistd.h>
+#include <fcntl.h>
 
 #include "threads.h"
 #include "logging.h"
@@ -657,11 +658,7 @@ int virEventPollInit(void)
         return -1;
     }
 
-    if (pipe(eventLoop.wakeupfd) < 0 ||
-        virSetNonBlock(eventLoop.wakeupfd[0]) < 0 ||
-        virSetNonBlock(eventLoop.wakeupfd[1]) < 0 ||
-        virSetCloseExec(eventLoop.wakeupfd[0]) < 0 ||
-        virSetCloseExec(eventLoop.wakeupfd[1]) < 0) {
+    if (pipe2(eventLoop.wakeupfd, O_CLOEXEC | O_NONBLOCK) < 0) {
         virReportSystemError(errno, "%s",
                              _("Unable to setup wakeup pipe"));
         return -1;
-- 
GitLab