tmedicci commented on code in PR #8985:
URL: https://github.com/apache/nuttx/pull/8985#discussion_r1164029169


##########
drivers/pipes/pipe.c:
##########
@@ -243,22 +264,48 @@ int pipe2(int fd[2], int flags)
       return ERROR;
     }
 
-  /* Get a write file descriptor */
+  /* Check for the O_NONBLOCK bit on flags */
+
+  blocking = (flags & O_NONBLOCK) == 0;
+
+  /* Get a write file descriptor setting O_NONBLOCK temporarily */
 
-  fd[1] = open(devname, O_WRONLY | flags);
+  fd[1] = open(devname, O_WRONLY | O_NONBLOCK | flags);
   if (fd[1] < 0)
     {
       goto errout_with_driver;
     }
 
-  /* Get a read file descriptor */
+  /* Clear O_NONBLOCK if it was set previously */
+
+  if (blocking)
+    {
+      ret = fcntl(fd[1], F_SETFL, flags & (~O_NONBLOCK));
+      if (ret < 0)
+        {
+          goto errout_with_driver;
+        }
+    }
+
+  /* Get a read file descriptor setting O_NONBLOCK temporarily */
 
-  fd[0] = open(devname, O_RDONLY | flags);
+  fd[0] = open(devname, O_RDONLY | O_NONBLOCK | flags);

Review Comment:
   Yes! Only one side must be changed to nonblocking temporarily. There is no 
need to make the same for the other side. I'll revert it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to