trouble using a PTY

Fred_Smith@computrition.com Fred_Smith@computrition.com
Sun Nov 3 05:08:00 GMT 2002



I'm trying to run some very simple code that uses ptys. The
code is from W. Richard Stevens APUE book. The only change is
the printf you see below. In this routine:
int
ptym_open(char *pts_name)
{
        int             fdm;
        char    *ptr1, *ptr2;
        strcpy(pts_name, "/dev/ptyXY");
          /* array index: 0123456789 (for references in following code) */
        for (ptr1 = "pqrstuvwxyzPQRST"; *ptr1 != 0; ptr1++) {
                pts_name[8] = *ptr1;
                for (ptr2 = "0123456789abcdef"; *ptr2 != 0; ptr2++) {
                        pts_name[9] = *ptr2;
                        /* try to open master */
                        if ( (fdm = open(pts_name, O_RDWR)) < 0) {
printf ("ptym_open, open returned errno of: %d, pts_name=%s\n",
errno,pts_name);
                                if (errno == ENOENT)    /* different from
EIO */
                                        return(-1);   /*out of pty devices
*/
                                else
                                        continue;    /*try next pty device
*/
                       }
                        pts_name[5] = 't';      /* change "pty" to "tty" */
                        return(fdm);            /* got it, return fd of
master */
                }
        }
        printf ("pty, at end, errno is: %d\n", errno);
        return(-1);             /* out of pty devices */
}
the first call to open() fails, and the printf produces:
     ptym_open, open returned errno of: 2, pts_name=/dev/ptyp0
As far as I can deduce by reading cygwin docs and mailing list archives,
PTYs would be expected to work.
I'd appreciate it if someone could point me in the right direction here.
attached is output of "cygcheck -s"
Thanks!
fred
(See attached file: cygcheck.out)



-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 15545 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20021103/9e2e57cc/attachment.obj>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list