LingaoM commented on code in PR #19515:
URL: https://github.com/apache/nuttx/pull/19515#discussion_r3643667748


##########
arch/sim/src/sim/posix/sim_hostuart.c:
##########
@@ -130,6 +131,71 @@ int host_uart_open(const char *pathname)
   return fd;
 }
 
+/****************************************************************************
+ * Name: host_uart_openpty
+ ****************************************************************************/
+
+int host_uart_openpty(const char *name)
+{
+#ifdef CONFIG_HOST_LINUX
+  unsigned int ptyno;
+  char msg[128];
+  char slave[64];
+  int lock = 0;
+  int oflags;
+  int ret;
+  int fd;
+
+  oflags = O_RDWR | O_NOCTTY | O_NONBLOCK;
+#ifdef O_CLOEXEC
+  oflags |= O_CLOEXEC;
+#endif
+  fd = open("/dev/ptmx", oflags);
+  if (fd < 0)
+    {
+      return -errno;
+    }
+
+  ret = ioctl(fd, TIOCGPTN, &ptyno);
+  if (ret < 0)
+    {
+      ret = -errno;
+      goto errout;
+    }
+
+  ret = ioctl(fd, TIOCSPTLCK, &lock);
+  if (ret < 0)
+    {
+      ret = -errno;
+      goto errout;
+    }
+
+  ret = snprintf(slave, sizeof(slave), "/dev/pts/%u", ptyno);
+  if (ret < 0 || ret >= (int)sizeof(slave))
+    {
+      ret = -ENAMETOOLONG;
+      goto errout;
+    }
+
+  setrawmode(fd);
+  ret = snprintf(msg, sizeof(msg), "%s connected to pseudotty: %s\n",
+                 name, slave);
+  if (ret > 0)
+    {
+      write(STDOUT_FILENO, msg, ret);

Review Comment:
   Yep, changed.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to