Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've been bitten by this, too, in the context of crash logging.</p> <p><code>FILE_FLAG_WRITE_THROUGH</code> only guarantees that the data you're sending gets sent to the <em>filesystem</em> before <code>WriteFile</code> returns; it doesn't guarantee that it's actually sent to the physical device. So, for example, if you execute a <code>ReadFile</code> after a <code>WriteFile</code> on a handle with this flag, you're guaranteed that the read will return the bytes you wrote, whether it got the data from the filesystem cache or from the underlying device.</p> <p>If you want to guarantee that the data has been written to the device, then you need <code>FILE_FLAG_NO_BUFFERING</code>, with all the attendant extra work. Those writes have to be aligned, for example, because the buffer is going all the way down to the device driver before returning.</p> <p>The Knowledge Base has a <a href="http://support.microsoft.com/kb/99794" rel="noreferrer">terse but informative article</a> on the difference.</p> <p>In your case, if the parent process is going to outlive the child, then you can:</p> <ol> <li>Use the <code>CreatePipe</code> API to create an inheritable, anonymous pipe.</li> <li>Use <code>CreateFile</code> to create a file with <code>FILE_FLAG_NO_BUFFERING</code> set.</li> <li>Provide the writable handle of the pipe to the child as its STDOUT.</li> <li>In the parent process, read from the readable handle of the pipe into aligned buffers, and write them to the file.</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload