On Tuesday, 3 February 2015 at 14:36:58 UTC, Adam D. Ruppe wrote:
On Tuesday, 3 February 2015 at 05:53:30 UTC, Jeremy DeHaan
Yes, they are not guaranteed to run, but isn't that only
during run time? They are going to be called at the
application exit to ensure everything is cleaned up.
If the application exits somewhat cleanly (through return from
main or even a thrown exception in D), it will run, though I'm
not sure if that's guaranteed or just an implementation
However, if the application exits differently, they won't
necessarily be run. For example, a Unix signal terminating the
process skips all the D cleanup tasks.
Often, this doesn't matter because the operating system will
clean up a lot of resources anyway. But if you are using
something like shared memory with another process, or expect a
file to be written to in a destructor, you'll find those things
I had this problem once in simpledisplay.d. When it died by
ctrl+c, the unix SIGINT was sent, and that skipped the
destructors for shared images. As a result, the system
eventually ran out of shared handles and most GUI programs
wouldn't start up anymore until I cleaned it up some other way.
Yikes, that's good to know.
Still, I feel like it could be worded a little better in the docs
and anywhere else they are talked about. I feel like it is just
far too ambiguous.