This is the mail archive of the
cygwin@sources.redhat.com
mailing list for the Cygwin project.
How to create tty/pty pair ?
- To: cygwin at cygwin dot com
- Subject: How to create tty/pty pair ?
- From: "Ehud Karni" <ehud at unix dot simonwiesel dot co dot il>
- Date: Sat, 30 Dec 2000 23:19:17 +0200
- Organization: Simon & Wiesel Insurance agency
- Reply-to: ehud at unix dot simonwiesel dot co dot il
I do not know how to make a tty/pty pair with Cygwin.
I went over the faq and the ncursus readme and did not find an answer
or a pointer to an answer to this question. Can the Cygwin gurus help
me on this ?
The only reference I found (in the faq is this:
Sergey Okhapkin (sos@prospect.com.ru) has been an invaluable Net
contributor. He implemented the tty/pty support, has played a
significant role in revamping signal and exception handling, and
has made countless contributions throughout the library. He also
provided binaries of the development snapshots to the Net after
the beta 19 release.
So I have the notion that tty/pty is supported on Cygwin.
Here is the code I use on Linux (and some other UNIX systems):
int allocate_pty ()
{
struct stat stb ;
int fd , i ;
for ( i = 1 ; i < 256 ; i++ )
{
sprintf (pty_name, "/dev/ptyp%d", i ) ;
if ( stat ( pty_name , & stb ) < 0 )
return -1;
fd = open (pty_name, O_RDWR | O_NONBLOCK, 0);
if ( fd >= 0 )
{
pty_name [5] = 't' ; /* change /dev/pty?? to /dev/tty?? */
if ( access ( pty_name, W_OK | R_OK ) != 0 )
{
close (fd);
continue ;
}
return fd;
}
}
return -1 ;
}
Ehud.
--
@@@@@@ @@@ @@@@@@ @ @ Ehud Karni Simon & Wiesel Insurance agency
@ @ @ @@ @ Tel: +972-3-6212-757 Fax: +972-3-6292-544
@ @ @ @ @ @@ (USA) Fax and voice mail: 1-815-5509341
@ @ @ @ @ @ Better Safe Than Sorry
http://www.simonwiesel.co.il mailto:ehud@unix.simonwiesel.co.il
--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple