From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:53058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUJ4Q-00019B-3h for qemu-devel@nongnu.org; Tue, 15 May 2012 10:50:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SUJ4G-0002zc-Ux for qemu-devel@nongnu.org; Tue, 15 May 2012 10:49:49 -0400 Received: from mail-qc0-f173.google.com ([209.85.216.173]:46477) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUJ4G-0002zK-OJ for qemu-devel@nongnu.org; Tue, 15 May 2012 10:49:40 -0400 Received: by qcsc20 with SMTP id c20so4836115qcs.4 for ; Tue, 15 May 2012 07:49:39 -0700 (PDT) Sender: fluxion From: Michael Roth Date: Tue, 15 May 2012 09:48:53 -0500 Message-Id: <1337093339-10786-8-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1337093339-10786-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1337093339-10786-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 07/13] qemu-ga: make reopen_fd_to_null() public List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mprivozn@redhat.com, aliguori@us.ibm.com, eblake@redhat.com, jcody@redhat.com, lcapitulino@redhat.com From: Luiz Capitulino The next commit wants to use it. Signed-off-by: Luiz Capitulino Reviewed-by: Eric Blake Signed-off-by: Michael Roth --- qemu-ga.c | 17 +++++++++++++++++ qga/commands-posix.c | 19 ------------------- qga/guest-agent-core.h | 4 ++++ 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/qemu-ga.c b/qemu-ga.c index cf61cb9..8d53e04 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 e448431..adb9b3d 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 -- 1.7.4.1