This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

trouble using a PTY

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:
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",
                                if (errno == ENOENT)    /* different from
EIO */
                                        return(-1);   /*out of pty devices
                                        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"
(See attached file: cygcheck.out)

Attachment: cygcheck.out
Description: Binary data

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]