Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Delivered-To: mailing list cygwin@cygwin.com X-Lotus-FromDomain: COMPUTRITION From: Fred_Smith@computrition.com To: egor duda Message-ID: <85256C66.00616DDA.00@cinote.computrition.com> Date: Sun, 3 Nov 2002 12:44:28 -0500 Subject: Re: trouble using a PTY Mime-Version: 1.0 Content-type: text/plain; charset=us-ascii Egor: Thanks for the info! Fred egor duda on 11/03/2002 09:47:53 AM Please respond to egor duda To: Fred Smith/Computrition cc: cygwin@cygwin.com Subject: Re: trouble using a PTY Hi! Sunday, 03 November, 2002 Fred_Smith@computrition.com Fred_Smith@computrition.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@logos-m.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/