www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - how to terminate a program

reply james <james google.com> writes:
how to terminate the program in the middle of execution, is there any command
such as halt,exit? since i dont use exception for error handling.
Oct 24 2008
parent reply dsimcha <dsimcha yahoo.com> writes:
== Quote from james (james google.com)'s article
 how to terminate the program in the middle of execution, is there any command
such as halt,exit? since i dont use exception for error handling. Use C's. It's in std.c.stdlib. It's called exit, takes an int and returns the exit code provided by the caller to the OS upon termination.
Oct 24 2008
next sibling parent james <james google.com> writes:
dsimcha Wrote:

 == Quote from james (james google.com)'s article
 how to terminate the program in the middle of execution, is there any command
such as halt,exit? since i dont use exception for error handling. Use C's. It's in std.c.stdlib. It's called exit, takes an int and returns the exit code provided by the caller to the OS upon termination.
thank you very much. it works.
Oct 24 2008
prev sibling parent reply Murilo <murilomiranda92 hotmail.com> writes:
On Saturday, 25 October 2008 at 01:41:09 UTC, dsimcha wrote:
 == Quote from james (james google.com)'s article
 how to terminate the program in the middle of execution, is 
 there any command
such as halt,exit? since i dont use exception for error handling. Use C's. It's in std.c.stdlib. It's called exit, takes an int and returns the exit code provided by the caller to the OS upon termination.
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?
Sep 14 2019
parent reply Jonathan M Davis <newsgroup.d jmdavisprog.com> writes:
On Saturday, September 14, 2019 9:37:37 PM MDT Murilo via Digitalmars-d 
wrote:
 On Saturday, 25 October 2008 at 01:41:09 UTC, dsimcha wrote:
 == Quote from james (james google.com)'s article

 how to terminate the program in the middle of execution, is
 there any command
such as halt,exit? since i dont use exception for error handling. Use C's. It's in std.c.stdlib. It's called exit, takes an int and returns the exit code provided by the caller to the OS upon termination.
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
Sep 14 2019
next sibling parent Murilo <murilomiranda92 hotmail.com> writes:
 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
Thanks man. Importing core.stdc.stdlib really worked. :)
Sep 15 2019
prev sibling parent reply FeepingCreature <feepingcreature gmail.com> writes:
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. :-)
Sep 16 2019
parent Jonathan M Davis <newsgroup.d jmdavisprog.com> writes:
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
Sep 17 2019