Bug 7160 - glibc read broken!
glibc read broken!
Status: CLOSED DEFERRED
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
6.1
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Cristian Gafton
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-11-19 18:19 EST by mark
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-01-04 19:20:52 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description mark 1999-11-19 18:19:46 EST
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 10:53:59 EST
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-04 19:20:59 EST
Waiting on feedback.

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