As far as I can see (at least in NetBSD) O_NONBLOCK and FIONBIO are equivalent,
authorben <ben@cda61777-01e9-0310-a592-d414129be87e>
Tue, 2 Oct 2007 21:07:52 +0000 (21:07 +0000)
committerben <ben@cda61777-01e9-0310-a592-d414129be87e>
Tue, 2 Oct 2007 21:07:52 +0000 (21:07 +0000)
except that O_NONBLOCK is standardised and FIONBIO isn't.  In consequence,
replace our only use of FIONBIO with O_NONBLOCK.

Inspired by Jonathan H N Chin, who had problems with this on Solaris.

git-svn-id: svn://svn.tartarus.org/sgt/putty@7753 cda61777-01e9-0310-a592-d414129be87e

unix/uxpty.c

index 60dc7f7..ca7e98a 100644 (file)
@@ -360,8 +360,10 @@ static void pty_open_master(Pty pty)
         /*
          * Set the pty master into non-blocking mode.
          */
-        int i = 1;
-        ioctl(pty->master_fd, FIONBIO, &i);
+        int fl;
+       fl = fcntl(pty->master_fd, F_GETFL);
+       if (fl != -1 && !(fl & O_NONBLOCK))
+           fcntl(pty->master_fd, F_SETFL, fl | O_NONBLOCK);
     }
 
     if (!ptys_by_fd)