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

tcflush () on SunOS and HP-UX

4 views
Skip to first unread message

Alex Vinokur

unread,
May 6, 1999, 3:00:00 AM5/6/99
to

Hi,

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 seems it isn't 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 -a : SunOS <nodename> 5.6 Generic_105181-09
sun4m sparc SUNW,SPARCstation-5

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

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


//#########################################################
//------------------- 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 -a : HP-UX <nodename> B.10.20 A 9000/847
1410304272 two-user license

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

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


##################################################################
############## 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) ###########################
##################################################################


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

0 new messages