Proper way to exit with specific exit code?

James Blachly james.blachly at gmail.com
Fri Sep 18 01:53:07 UTC 2020


On 9/17/20 12:46 PM, IGotD- wrote:
> The only way is to return from main. The thing is that druntime runs 
> initialization before main and then returning from main it runs all the 
> tear down code including cleaning up the GC. This means there is no 
> equivalent of the exit function in the C library. Calling exit from D 
> means that there will be no cleanup in D environment.
...

I never considered this -- so when I call core.stdc.stdlib : exit, none 
of my destructors get called?

Presumably also not scope(exit) blocks?

If this is the case, could we simply add a publically-accessible 
shutdown hook in the runtime?



More information about the Digitalmars-d-learn mailing list