delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/09/15/10:39:27

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
From: u98saino AT eniac DOT sci DOT kagoshima-u DOT ac DOT jp (Hiroshi Sainohira)
To: cygwin AT cygwin DOT com
Subject: flushinp on /dev/ptmx
Date: Mon, 15 Sep 2003 23:39:16 JST
Message-ID: <030915233916.M0129843@edsac.sci.kagoshima-u.ac.jp>

Hi, there.

I am making a program which uses Ncurses and flushinp.
But I have a problem about flushinp.
Though this routine worked very fine when I executed 
the program on the cygwin's default window, it didn't on 
rxvt or cygterm.
To clear this problem, I tested a short code as follows:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <termios.h>

main()
{
    int master, slave;
    char buf[256];

    /* Open pseudo terminal */
    if ((master = open("/dev/ptmx", O_RDWR)) < 0) {
        return -1;
    }

    if (fork() > 0) {
     /* store buffers.*/
        write(master, "123456789\n", 10);
        sleep(4);
        exit(0);
    } else {
      if ((slave = open(ptsname(master), O_RDWR)) < 0) {
        exit(0);
      }
        close(master);
        sleep(2);
        tcflush(slave, TCIFLUSH); /* flushinp */
      
        /* Check whether input buffers are thrown away.*/
        memset(buf, 0, sizeof(buf));
        read(slave, buf, 10);
        printf("%s", buf);
        exit(0);
    }
}

When I ran this code on Solaris8 or Linux,
the child process threw away "123456789\n".
But when on cygwin window, the string keeped on 
and was printed by child process.

Does the pseudo terminal of cygwin( /dev/ptmx ) support
flushing input buffer?

Cygwin's Version is the 1.5.4-1.

Thank you.

					Hiroshi Sainohira

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.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