Reputation: 1
I'm trying to chase down an intermittent SEG FAULT on an ostream insert and I've come across code that looks something like this:
#include <fcntl.h>
...
std::filebuf logBuf;
std::ostream fout;
int logFD = open(myfile, O_RDWR|O_CREAT|O_TRUNC|O_APPEND, S_IRUSR|S_IWUSR);
logBuf.open(myFile, ios::out|ios::app);
fout.rdbuf(&logBuf);
This doesn't feel right, but I can't find anything that says whether it is safe to mix IO styles on a file like this.
Does this need a rewrite or am I barking up the wrong tree?
Upvotes: 0
Views: 33