[Ns-bugs] [Bug 931] NS_ASSERT reports SIGSEGV on failure
code@nsnam.ece.gatech.edu
code at nsnam.ece.gatech.edu
Tue Jun 1 00:25:34 PDT 2010
http://www.nsnam.org/bugzilla/show_bug.cgi?id=931
--- Comment #6 from Mathieu Lacage <mathieu.lacage at sophia.inria.fr> 2010-06-01 03:25:33 EDT ---
(In reply to comment #5)
> (In reply to comment #4)
> > (In reply to comment #3)
> > > If possible, I'd really like the program to flush and close all trace files
> > > that are open if performing a cleanup.
> >
> > It's not really easy to do. You need to flush all opened std::ostream files.
> > For FILE* things, it's easy to call fflush (0) but I am not aware of the
> > std::ostream equivalent. Given the implementation of the std::ostream class in
> > the libstdc++ library, I suspect that calling fflush(0) might just work, even
> > for streams opened through std::ostream but I don't have time to try this.
>
>
> Naah, does not work:
>
>
> #include <iostream>
> #include <fstream>
> #include <stdio.h>
>
> int main(int argc, char *argv[])
> {
> std::ofstream os;
> char buffer[10];
> os.open("test.foo", std::ios_base::out);
>
> os.write(buffer, 10);
>
> fflush (0);
>
> sleep (20);
>
> return 0;
> }
The quick hack would be to make PcapFile keep track of all opened std::ofstream
instances in a global variable and provide a static member method Flush which
calls the flush of each individual stream.
--
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the Ns-bugs
mailing list