How to create tty/pty pair ?

Christopher Faylor
Thu Jan 4 14:42:00 GMT 2001

On Sat, Dec 30, 2000 at 11:19:17PM +0200, Ehud Karni wrote:
>I do not know how to make a tty/pty pair with Cygwin.

/dev/ptmx is the mechanism.  Here is some sample code:

    char *slave;
    int om = open ("/dev/ptmx", O_RDWR);
    if (om < 0)
      die ("/dev/ptmx", 1);

    if (grantpt (om) < 0)
      die ("grantpt", 2);

    if (unlockpt (om) < 0)
      die ("unlockpt", 3);

    slave = ptsname (om);
    if (slave == NULL)
      die ("ptsname", 4);


Want to unsubscribe from this list?
Check out:

More information about the Cygwin mailing list