aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/utils.c15
1 files changed, 15 insertions, 0 deletions
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;
+}