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

Jonathan M Davis newsgroup.d at jmdavisprog.com
Tue Sep 17 08:39:32 UTC 2019


On Monday, September 16, 2019 1:24:02 AM MDT FeepingCreature via 
Digitalmars-d wrote:
> On Sunday, 15 September 2019 at 03:54:01 UTC, Jonathan M Davis
>
> wrote:
> > 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. :-)

Calling exit is akin to just shooting your process in the head.

- Jonathan M Davis





More information about the Digitalmars-d mailing list