Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

Bug 7160

Summary: glibc read broken!
Product: [Retired] Red Hat Linux Reporter: mark
Component: glibcAssignee: Cristian Gafton <gafton>
Status: CLOSED DEFERRED QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: 6.1   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-01-05 00:20:52 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

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.