Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tcflush on SunOS and HP-UX

9 views
Skip to first unread message

Alex Vinokur

unread,
Nov 1, 1999, 3:00:00 AM11/1/99
to
In article <slrn81c9...@pulsar.halcyon.com>,
k...@halcyon.com wrote:
[snip]
> Otherwise you probably will need to resort to compiling this
> "flushi" program and installing it somewhere in your $PATH:
> #include <unistd.h>
> #include <termios.h>
> int main(void) { tcflush(STDIN_FILENO, TCIFLUSH); return 0; }
>
> --Ken Pizzini
>

I have got a trouble with the tcflush () function.

The same program was compiled on SunOS and HP-UX 10.
The program contains the tcflush () function.

But for some reason the results of the running
on SunOS and HP-UX 10 are different.
The program works OK on SunOS,
but it doesn't seem to be OK on HP-UX 10.

Does anybody know what is wrong?

Thanks in advance,
Alex

//#########################################################
//------------------- C++ code : BEGIN -------------------

#include <string>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <termios.h>
int main(void)
{
string s1;

while (1)
{
switch (tcflush(0, TCIFLUSH))
{
case 0 :
// OK
break;

case 1 :
cout << "FATAL ERROR : "
<< (strerror (errno))
<< endl;
exit (1);
break; // unused

default :
abort ();
break; // unused
} // switch (tcflush(0, TCIFLUSH))

cout << "Enter : ";
cin >> s1;
cout << "\tValue = " << s1 << endl;
sleep (5);
}
return 0;
}

//------------------- C++ code : END ----------------------


//#########################################################
//------------------- Running Results : BEGIN -------------
//------------------- SunOS -------------------------------

//=== Running ====
%a.out
Enter : aaaaa // aaaaa is input data
Value = aaaaa
bbbbb // bbbbb is input data
ccccc // ccccc is input data
Enter : ddddd // ddddd is input data
Value = ddddd
cntrl-c

//=== Conclusion ====
The data, received but not read, are flushed : bbbbb, ccccc

//------------------- SunOS -------------------------------
//------------------- Running Results : END ---------------

//#########################################################
//------------------- Compiler & System ------------------
//------------------- SunOS -------------------------------

g++ -v : gcc version egcs-2.91.57 19980901
(egcs-1.1 release)

uname -sa : SunOS 5.6

//---------------------------------------------------------

//#########################################################


//#########################################################
//------------------- Running Results : BEGIN -------------
//------------------- HP-UX -------------------------------

//=== Running ====
%a.out
Enter : aaaaa // aaaaa is input data
Value = aaaaa
bbbbb // bbbbb is input data
ccccc // ccccc is input data
Enter : Value = bbbbb // ???
Enter : Value = ccccc // ???
Enter : ddddd // ddddd is input data
Value = ddddd
cntrl-c

//=== Conclusion ====
No data are flushed.

//------------------- HP-UX -------------------------------
//------------------- Running Results : END ---------------

//#########################################################
//------------------- Compiler & System ------------------
//------------------- HP-UX -------------------------------

g++ -v : gcc version 2.8.1
aCC : HP aC++ B3910B A.01.06
HP aC++ B3910B A.01.01 Support Library
Note! The same results were obtained using both g++ and aCC.

uname -sa : HP-UX B.10.20

//---------------------------------------------------------

//#########################################################


##################################################################
############## SunOS information (BEGIN) #########################
##################################################################
SunOS 5.6
Last change: 29 Dec 1996
##################################################################

man tcflush contains the following information :
================================================

NAME
tcflush - flush non-transmitted output data, non-read input
data or both

SYNOPSIS
#include <termios.h>

int tcflush(int fildes, int queue_selector);

DESCRIPTION
Upon successful completion, tcflush() discards data written
to the object referred to by fildes (an open file descriptor
associated with a terminal) but not transmitted, or data
received but not read, depending on the value of
queue_selector:

o If queue_selector is TCIFLUSH it flushes data received but
not read.

[snip]

RETURN VALUES
Upon successful completion, 0 is returned. Otherwise, -1 is
returned and errno is set to indicate the error.

[snip]

##################################################################
############## SunOS information (END) ###########################
##################################################################


##################################################################
############## HP-UX information (BEGIN) #########################
##################################################################
Hewlett-Packard Company
HP-UX Release 10.20: July 1996
##################################################################

man tcflush contains the following information :
================================================

NAME
tcsendbreak(), tcdrain(), tcflush(), tcflow() - tty line control
functions

SYNOPSIS
#include <termios.h>
[snip]

int tcflush(int fildes, int queue_selector);

[snip]

DESCRIPTION

[snip]

tcflush() discards data written to fildes but not transmitted, or
data
received but not read, depending on the value of queue_selector:

+ If queue_selector is TCIFLUSH, data received but not read
is
flushed.

[snip]

RETURN VALUE
Upon successful completion, a value of zero is returned.
Otherwise, a
value of -1 is returned and errno is set to indicate the error.

[snip]

##################################################################
############## HP-UX information (END) ###########################
##################################################################


Sent via Deja.com http://www.deja.com/
Before you buy.

0 new messages