Re:Don't setenv in multi-threaded code on glibc
by mzs on Tuesday January 31, 2017 @04:39PM
(#13535497)
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() ;)
[ Parent
| on HN ]
Re:Don't setenv in multi-threaded code on glibc
by quotemstr on Tuesday January 31, 2017 @05:23PM
(#13535889)
Your 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.