Red Hat Bugzilla – Bug 65055
stat on fifo always returns st_size=0, but worked in previous versions
Last modified: 2016-10-03 05:18:56 EDT
Description of Problem:
Executing fstat on a named pipe (fifo) always returns 0 when running Linux
version 2.4.7-10 ( RedHat 7.2 ). Under Linux version 2.2.17-14 ( RedHat 7.0 ),
the same fstat always returned the correct number of unread bytes in the fifo.
Version-Release number of selected component (if applicable):
kernel version 2.4.7-10
Here is the source code necessary to reproduce
int main( int ac, char * av )
struct stat s;
sleep( 5 );
fstat( 0, &s);
printf( "bytes:%u\n", s.st_size );
Steps to Reproduce:
1. Compile the above source using "gcc -o <filename> <filename>.c"
2. At a linux prompt, enter %> echo "12345" | ./<filename>
3. It should print 'bytes:6' when working properly.
You can also change the string length in the echo to get different values when
running on the older version of linux mentioned above.
Bug #60395 actually described the same problem, but provided a bogus
explanation as to the cause of the problem. The information we get from this
test program is that the stat always returns correct sizes on previous versions
of Linux, not random values as the developer stated in bug #60395. If the
statements in bug #60395 are supposed to be accurate, how in the world do you
get the number of unread bytes in the fifo before doing the actual read???