I am considering using named pipes for debug output from a DLL. My DLL is loaded by a proprietary closed source program which crashes now and then. The problem is that when the program crashes some of my current log output gets lost because windows cleans up everything before it is written to disk.
So my question is if I create a named pipe in a separate process and connect to it from my DLL and the process my DLL is in crashes and is cleaned up will I still be able to read data that was written into the named pipe just before the crash from my second process?
I have to write into the Named pipe in a non blocking (buffered) manor as to affect timing as little as possible, what is the best configuration? Overlapped IO? Can someone give a link to good reading? (I’m not a C++ beginner but I am a WinAPI beginner)
I don’t believe the named pipe buffered data survives the failure of one partner. Even if you manage to reopen the pipe any data from the old instantiation will be gone.
You could use Memory-Mapped Files (Windows mechanism for interprocess shared memory) instead but you’d have to be careful about handling the state of the shared data space – where to resume writing new data when the process wakes up again? Some kind of “I’ve read this far” indication from the sink, maybe. You’d also have to flush data on write in the source to avoid the problem you recognised with this question, that might make performance subpar but you could test first, tune later.