lkml.org 
[lkml]   [1998]   [Aug]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Bug in kernel or libc !?
Why do you think there is any bug?

[...]
bank = fopen("test","r+");

You open a file using stdio.

fseek(bank,0L,0);
fread(buf,512,1,bank);
fseek(bank,0L,0);

You read the data from it then to back to the start.

//fflush(bank); //uncoment this for bugfix

ftruncate( fileno(bank), 0 );

You do something bad by improperly using stdio; before you can do anything
with fileno() you need to fflush the stream. The Solaris man page for
stdio has a reasonable discussion of this.

Any behaviour now is undefined because you are mixing stdio and non-stdio
on the same descriptor without proper caution.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html

\
 
 \ /
  Last update: 2005-03-22 13:44    [W:0.100 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site