how to terminate a program - exit(), destructors and issue 19978

FeepingCreature feepingcreature at
Mon Sep 16 07:24:02 UTC 2019

On Sunday, 15 September 2019 at 03:54:01 UTC, Jonathan M Davis 
> On Saturday, September 14, 2019 9:37:37 PM MDT Murilo via 
> Digitalmars-d wrote:
>> Hi, I am trying it but my compiler does not find the 
>> std.c.stdlib module. I am using one of the latest versions. 
>> Has it been removed?
> You're replying to a post that's nearly 11 years old. The C 
> bindings were moved to druntime quite some time ago. The 
> bindings for C's standard library are in the package core.stdc. 
> So, the bindings for C's stdlib header are in core.stdc.stdlib.
> - Jonathan M Davis

Gonna take this opportunity to bring up two related concerns.

First: when you exit the program via exit(), module destructors 
will not be run. As a result, any modules that rely on this, such 
as database drivers that close file handles, flush caches to 
disk, etc. will not get a chance to react.

On the other hand, you will also sidestep issue 19978 which notes 
that sometimes, D programs (with daemon threads) just randomly 
crash on exit and nobody knows why.

So you know, you win some, you lose some. :-)

More information about the Digitalmars-d mailing list