implement poll and read
[~madcoder/pwqr.git] / lib / libpwqr.c
index f5d53a2..85cccac 100644 (file)
 /* }}} */
 /* pwqr wrapping {{{ */
 
-static int pwqr_create(void)
+static int pwqr_create(int flags)
 {
-    return open("/dev/"PWQR_DEVICE_NAME, O_RDWR);
+    if (flags & ~(O_NONBLOCK | O_CLOEXEC)) {
+        errno = -EINVAL;
+        return -1;
+    }
+    return open("/dev/"PWQR_DEVICE_NAME, O_RDWR | flags);
 }
 
 static int pwqr_ctl(int fd, int op, int val, void *uaddr)
@@ -328,7 +332,7 @@ static int _pthread_workqueue_init_np(void)
     if (pwqr_g.fd >= 0)
         goto out;
 
-    fd = pwqr_create();
+    fd = pwqr_create(0);
     if (fd < 0) {
         rc = -1;
         goto out;