+ /*
+ * Make the new pty our controlling terminal. On some OSes
+ * this is done with TIOCSCTTY; Cygwin doesn't have that, so
+ * instead it's done by simply opening the pty without
+ * O_NOCTTY. This code is primarily intended for Cygwin, but
+ * it's useful to have it work in other contexts for testing
+ * purposes, so I leave the TIOCSCTTY here anyway.
+ */
+ if ((fd = open(ptyname, O_RDWR)) >= 0) {