Append-mode I/O on Windows and process I/O redirection

Alan Bateman Alan.Bateman at Sun.COM
Sat Jun 7 16:12:24 UTC 2008


Martin Buchholz wrote:
> :
>
> I suppose we'll sadly have to back out all the changes for 6631352.
> Another strategy is to open the file in FILE_WRITE_DATA mode as before,
> but to make each individual write work in append mode.
> Another look at the msdn documentation suggests that this is possible
> (did I miss this when I explored the docs a year ago?)
>
> http://msdn.microsoft.com/en-us/library/aa365747(VS.85).aspx
>
> Use WriteFile with a non-null OVERLAPPED, with Offset = OffsetHigh = 0xffffffff
>
> "To write to the end of file, specify both the Offset and OffsetHigh
> members of the OVERLAPPED structure as 0xFFFFFFFF. This is
> functionally equivalent to previously calling the CreateFile function
> to open hFile using FILE_APPEND_DATA access."
>
> The above has a good chance of properly fixing 6631352.
>   
I agree this is the approach to try. I've used WriteFile for append mode 
using this approach in another context and it worked although I don't 
recall ever checking its atomicity. The MSDN documentation is never 
clear on such topics but the AtomicAppend test that you included with 
these changes can quickly check.

> What should the process code do, given that it doesn't control
> how the subprocess will perform individual writes?
>   
Maybe ProcessBuilder can open the file itself in append mode rather than 
using FileOutputStream.

-Alan.



More information about the core-libs-dev mailing list