Bug 7160 - glibc read broken!
Summary: glibc read broken!
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 6.1
Hardware: i386
OS: Linux
medium
high
Target Milestone: ---
Assignee: Cristian Gafton
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 1999-11-19 23:19 UTC by mark
Modified: 2008-05-01 15:37 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2000-01-05 00:20:52 UTC
Embargoed:


Attachments (Terms of Use)

Description mark 1999-11-19 23:19:46 UTC
I have:
glibc-2.1-990920.tar.gz from RedHat 6.1
glibc-990416.tar.gz         from RedHat 6.0

Running RedHat 6.1 on a dual processor Intel pII with
glibc-2.1-990920.tar.gz  appears to have a problem of dropping the last
character when read is called to a serial device.

fd is an open file descriptor of a serial port set to block one
character.
Data is in the form of dec 70 some ascii string terminated by dec 13  or
dec 10(depends on which version of library used)  This data is comming
from a  barcode reader and unfortunately  I'm not sure of the correct
value of the terminator.

In glibc-2.1-990920.tar.gz(2.1.2)  :
This works and includes the decimal 13 terminator  :
char c;
while (1)
{
         read(fd,&c,1);
        printf("c is %d\n",c);
}
Output is :
c is 70
c is 57
c is 55
c is 56
c is 48
c is 50
c is 48
c is 49
c is 51
c is 48
c is 56
c is 50
c is 49
c is 49
c is 13

This drops the last character which is a decimal 13:
char buff[255];
while(1)  {
      read(fd, buff,1);
      printf("buff is %d \n",  buff[0]);
}
buff is 70
buff is 57
buff is 55
buff is 56
buff is 48
buff is 50
buff is 48
buff is 49
buff is 51
buff is 48
buff is 56
buff is 50
buff is 49
buff is 49
                -<<<<what happend to the terminator????

In glibc-990416.tar.gz(2.1.1) both cases work but the string is
terminated by DEC 10.

I tried a clean version of glibc-2.1.2 from sourceware.cygnus.com
and have the same problem with the terminator being dropped if the data
is stored in a char array.  BUT the character is not dropped if the data
is stored in a character.

Comment 1 Jeff Johnson 1999-11-27 15:53:59 UTC
What is displayed if you check the read system call for errors?

         if (read(fd,&c,1) < 0)
		perror("read");

Comment 2 Cristian Gafton 2000-01-05 00:20:59 UTC
Waiting on feedback.


Note You need to log in before you can comment on or make changes to this bug.