From 232c9f6c41387bc3cf1c239e0ce4caafbbb76c67 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 26 Mar 2008 10:39:03 +0000 Subject: notify: cleanups * move set_nonblock{,ing}() into utils.c since we use it elsewhere, too * add proper error checking to set_nonblocking() * use os_compat.h instead of individually #includ-ing system headers git-svn-id: https://svn.musicpd.org/mpd/trunk@7217 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/utils.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index 8f18a80ff..1ff9a1910 100644 --- a/src/utils.c +++ b/src/utils.c @@ -214,3 +214,18 @@ char *parsePath(char *path) return newPath; } + +int set_nonblocking(int fd) +{ + int ret, flags; + + assert(fd >= 0); + + while ((flags = fcntl(fd, F_GETFL)) < 0 && errno == EINTR) ; + if (flags < 0) + return flags; + + flags |= O_NONBLOCK; + while ((ret = fcntl(fd, F_SETFL, flags)) < 0 && errno == EINTR) ; + return ret; +} -- cgit v1.2.3