chiark / gitweb /
cprogs: Move nonblock() to common.[co]
[chiark-utils.git] / cprogs / common.c
index b0542926a29085f660a7b653f3a1883452122281..e8efed6639801ea538a73551b89962bed6b52618 100644 (file)
@@ -41,3 +41,10 @@ void *xmalloc(size_t sz) {
   if (!r) common_diee("malloc");
   return r;
 }
+
+void nonblock(int fd) {
+  int r;
+  r= fcntl(fd,F_GETFL);  if (r<0) common_diee("nonblock fcntl F_GETFL");
+  r |= O_NONBLOCK;
+  r= fcntl(fd,F_SETFL,r);  if (r<0) common_diee("nonblock fcntl F_GETFL");
+}