delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/07/07/05:40:50

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
X-Envelope-Sender-Is: Andrej DOT Borsenkow AT mow DOT siemens DOT ru (at relayer david.siemens.de)
From: "Andrej Borsenkow" <Andrej DOT Borsenkow AT mow DOT siemens DOT ru>
To: <cygwin AT sourceware DOT cygnus DOT com>
Subject: Problems with pty under Cygwin
Date: Fri, 7 Jul 2000 13:39:54 +0400
Message-ID: <000601bfe7f7$4e52f0a0$21c9ca95@mow.siemens.ru>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0)
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Importance: Normal
In-Reply-To: <200007041321.JAA15692@envy.delorie.com>

A program opens pty and starts external command attached to the slave
side. Parent reads from master side a character at a time in
non-blocking mode. The problem is, parent gets EOF (read() returns zero)
after every line of child output.

The pty is opened with:

static int
get_pty(int master, int *retfd)
{
    static char *name;
    static int mfd, sfd;

    int ret;

    if (master) {
        if ((mfd = open("/dev/ptmx", O_RDWR)) < 0)
            return 1;

        if (grantpt(mfd) || unlockpt(mfd) || !(name = ptsname(mfd))) {
            close(mfd);
            return 1;
        }
        *retfd = mfd;

        return 0;
    }
    if ((sfd = open(name, O_RDWR)) < 0) {
        close(mfd);
        return 1;
    }

    *retfd = sfd;

    return 0;
}


It is based on API list that mentions grantpt() & Co.

What do I do wrong? The same program runs fine on Unix returning full
child output.

-andrej


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


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