delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/11/03/09:48:13

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Sun, 3 Nov 2002 17:47:53 +0300
From: egor duda <deo AT logos-m DOT ru>
Reply-To: egor duda <cygwin AT cygwin DOT com>
Organization: deo
X-Priority: 3 (Normal)
Message-ID: <82257138816.20021103174753@logos-m.ru>
To: Fred_Smith AT computrition DOT com
CC: cygwin AT cygwin DOT com
Subject: Re: trouble using a PTY
In-Reply-To: <85256C66.0048478C.00@cinote.computrition.com>
References: <85256C66 DOT 0048478C DOT 00 AT cinote DOT computrition DOT com>
MIME-Version: 1.0

Hi!

Sunday, 03 November, 2002 Fred_Smith AT computrition DOT com Fred_Smith AT computrition DOT com wrote:

Fcc> I'm trying to run some very simple code that uses ptys. The
Fcc> code is from W. Richard Stevens APUE book. The only change is

This code is non-portable. The names of ptys are system-specific, and
not guaranteed to be named /dev/ptyXY.

On cygwin, master side of pseudo tty can be opened via
open("/dev/ptym",...). Then you can use grantpt(), unlockpt() and
ptsname() functions to access a slave side of pty.

Unfortunately, its not very portable, either. Proposed portable
interface to open master side of pseudo tty is posix_openpt(), but it
haven't been implemented on cygwin yet. "Patches are gratefully
accepted" (tm).

BTW, implementing this function looks like an easy prey for those who
wish to contribute something to cygwin, but afraid of complexities of
cygwin internals.

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

Egor.            mailto:deo AT logos-m DOT ru ICQ 5165414 FidoNet 2:5020/496.19


--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019