This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

flushinp on /dev/ptmx


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]