X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com Message-ID: <529DD111.8050000@gmx.de> Date: Tue, 03 Dec 2013 13:39:45 +0100 From: Juan Manuel Guerrero User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: Question about different behavior of fclose/fread on plain dos and windows. References: <529D448A DOT 7050208 AT gmx DOT de> <831u1u5se3 DOT fsf AT gnu DOT org> In-Reply-To: <831u1u5se3.fsf@gnu.org> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:uSv7zjNj/cpEGpUdjXWcbVCMkcWmT/dGmo37kvC/k+ohL+diH+s WjsqX+/eFKUGvhmKNMIap7VCXuo2A2AnNkIsTUeOiFBcwNqjDPdesWG8V2ztoOY4UNV3h+t hipQqN0xZDv24nRHVPzKbjoD0fA+X72DJyWAiCFLJl5NVJXHfC+Vk4hWVSxK+YiVkhrNMBO GjIwRYxNLBP5Nzp5fr4Yw== Reply-To: djgpp AT delorie DOT com Am 03.12.2013 08:02, schrieb Eli Zaretskii: >> Date: Tue, 03 Dec 2013 03:40:10 +0100 >> From: Juan Manuel Guerrero >> >> The code shall open the same file for writing and reading. I have compiled >> the code on linux and on Win98SE, Win2K and WinXP. On windows I have used >> DJGPP 2.03 and DJGPP 2.04. In all these cases the code works as I expected. >> This means that reading after having closed the file shall result in a filled >> buf_r. The program gives the following output: >> >> fwrite(fw) OK (7): pipapo >> fread(fr) OK (0): >> fread(fr) OK (7): pipapo >> >> >> But if I compile the same code on plain DOS (MSDOS 6.22 or MSDOS 7.1) the program >> fails producing the following output: >> fwrite(fw) OK (7): pipapo >> fread(fr) OK (0): >> fread(fr) FO (0): >> >> >> (If you run the program twice on plain dos remove the produced file.txt before >> starting the program or the program will seem to work.) > Does it work reliably if you open the file for reading only after its > write handle is closed? How about if you call clearerr on the stream, > before the second read? It has no influence if I call clearerr. The flags that are cleared are not set before the call. It works reliably in all variants if I open the file for reading after having closed the write handle. Regards, Juan M. Guerrero