diff mbox

[1/2] qemu-ga: make reopen_fd_to_null() public

Message ID 1336679442-19198-2-git-send-email-lcapitulino@redhat.com
State New
Headers show

Commit Message

Luiz Capitulino May 10, 2012, 7:50 p.m. UTC
The next commit wants to use it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 qemu-ga.c              |   17 +++++++++++++++++
 qga/commands-posix.c   |   19 -------------------
 qga/guest-agent-core.h |    4 ++++
 3 files changed, 21 insertions(+), 19 deletions(-)

Comments

Eric Blake May 10, 2012, 8:14 p.m. UTC | #1
On 05/10/2012 01:50 PM, Luiz Capitulino wrote:
> The next commit wants to use it.
> 
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
>  qemu-ga.c              |   17 +++++++++++++++++
>  qga/commands-posix.c   |   19 -------------------
>  qga/guest-agent-core.h |    4 ++++
>  3 files changed, 21 insertions(+), 19 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox

Patch

diff --git a/qemu-ga.c b/qemu-ga.c
index 216be39..7896565 100644
--- a/qemu-ga.c
+++ b/qemu-ga.c
@@ -140,6 +140,23 @@  static gboolean register_signal_handlers(void)
 
     return true;
 }
+
+/* TODO: use this in place of all post-fork() fclose(std*) callers */
+void reopen_fd_to_null(int fd)
+{
+    int nullfd;
+
+    nullfd = open("/dev/null", O_RDWR);
+    if (nullfd < 0) {
+        return;
+    }
+
+    dup2(nullfd, fd);
+
+    if (nullfd != fd) {
+        close(nullfd);
+    }
+}
 #endif
 
 static void usage(const char *cmd)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index d58730a..2ce9b82 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -34,25 +34,6 @@ 
 #endif
 #endif
 
-#if defined(__linux__)
-/* TODO: use this in place of all post-fork() fclose(std*) callers */
-static void reopen_fd_to_null(int fd)
-{
-    int nullfd;
-
-    nullfd = open("/dev/null", O_RDWR);
-    if (nullfd < 0) {
-        return;
-    }
-
-    dup2(nullfd, fd);
-
-    if (nullfd != fd) {
-        close(nullfd);
-    }
-}
-#endif /* defined(__linux__) */
-
 void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err)
 {
     int ret;
diff --git a/qga/guest-agent-core.h b/qga/guest-agent-core.h
index bbb8b9b..6dba104 100644
--- a/qga/guest-agent-core.h
+++ b/qga/guest-agent-core.h
@@ -35,3 +35,7 @@  void ga_set_response_delimited(GAState *s);
 bool ga_is_frozen(GAState *s);
 void ga_set_frozen(GAState *s);
 void ga_unset_frozen(GAState *s);
+
+#ifndef _WIN32
+void reopen_fd_to_null(int fd);
+#endif