3 ms·
Not really, here's a different example where locking would not help you with file streams. You expect all streams to be flushed on exit() but I can't think of a
by mzs 10y ago
Not really, here's a different example where locking would not help you with file streams. You expect all streams to be flushed on exit() but I can't think of a unix-like that handles at_exit(_exit); correctly then, correctly in the sense that the streams no longer get flushed. In fact I have used this feature to prevent that flushing on exit() ;)
- quotemstr 10y agoYour example doesn't result in a deadlock or undefined behavior though. It just results in some at-exit code not being run. Really, programs shouldn't expect _anything_ to happen on exit. After all, programs can die at any time for any reason anyway. Personally, I'd do away with both atexit and static destructors. Your program needs to be able to handle the power cord being yanked, so it needs to be able to handle sudden death no matter what.
- deleted 10y ago[deleted]