From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ujxlr-000146-B4 for qemu-devel@nongnu.org; Tue, 04 Jun 2013 16:24:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ujxlm-0005oO-O7 for qemu-devel@nongnu.org; Tue, 04 Jun 2013 16:23:55 -0400 From: Alon Levy Date: Tue, 4 Jun 2013 16:23:35 -0400 Message-Id: <1370377419-31788-1-git-send-email-alevy@redhat.com> Subject: [Qemu-devel] [PATCH 1/5] oslib-posix: add qemu_pipe_non_block List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, qemu-trivial@nongnu.org Used by the followin patch. Signed-off-by: Alon Levy --- include/qemu-common.h | 1 + util/oslib-posix.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/qemu-common.h b/include/qemu-common.h index cb82ef3..c24d75c 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -232,6 +232,7 @@ ssize_t qemu_recv_full(int fd, void *buf, size_t count, int flags) #ifndef _WIN32 int qemu_pipe(int pipefd[2]); +int qemu_pipe_non_block(int pipefd[2]); #endif #ifdef _WIN32 diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 3dc8b1b..bc2ce2e 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -188,6 +188,25 @@ int qemu_pipe(int pipefd[2]) return ret; } +int qemu_pipe_non_block(int pipefd[2]) +{ + int ret; + + ret = qemu_pipe(pipefd); + if (ret) { + return ret; + } + if (fcntl(card->pipe[0], F_SETFL, O_NONBLOCK) == -1) { + return -errno; + } + if (fcntl(card->pipe[1], F_SETFL, O_NONBLOCK) == -1) { + return -errno; + } + if (fcntl(card->pipe[0], F_SETOWN, getpid()) == -1) { + return -errno; + } +} + int qemu_utimens(const char *path, const struct timespec *times) { struct timeval tv[2], tv_now; -- 1.8.2.1