File buffering

Damjan Jovanovic damjan.jov at gmail.com
Thu Jan 18 00:38:22 CST 2007


On 1/17/07, Teemu Ikonen <tpikonen at gmail.com> wrote:
> Hi,
>
> I have a Visual Fortran application which exhibits problems related to
> concurrency and file buffer flushing when run under wine (it works
> under all versions of windows).
>
> The program does essentially this:
>
> opens a file
> writes to it
> closes it
> forks another program to read the file just written
> deletes the file in the original process
>
> Under wine, the forked program does not find the file just written. If
> I run the program under winedbg and set a breakpoint somewhere between
> writing and deletion, the buffers are flushed when the breakpoint is
> reached, and the program works as it does under windows.

If you don't wait for the forked process to finish before deleting the
file, then you have a bug called a race condition which apparently
manifests in wine and not in Windows: you're relying on the forked
process to open the file before it gets deleted.

Either wait for the forked process to finish and then delete the file,
or have the forked process delete the file.

> To my mind this would indicate that windows flushes all open buffers
> before forking a new process (the api call I see in wine debug output
> is CreateProcessW). Would it make sense to add flush-calls to the wine
> implementation as well? I tried to make the program work by adding
> calls to the Fortran subroutine FLUSH between closing and forking, but
> somewhat surprisingly, that didn't help.

Doesn't closing a file automatically flush it?

> Teemu

Damjan



More information about the wine-devel mailing list