www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to exit a process?

reply Adam Ruppe <destructionator gmail.com> writes:
Is there a thing like C's exit() for a D program? Is
simply using C's function good enough?
Dec 06 2010
next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
I usually use assert(0) when I want to forcefully exit a program. It's
compiled in both debug/release modes.

On 12/6/10, Adam Ruppe <destructionator gmail.com> wrote:
 Is there a thing like C's exit() for a D program? Is
 simply using C's function good enough?

Dec 06 2010
prev sibling next sibling parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Mon, 06 Dec 2010 14:11:59 -0500, Adam Ruppe <destructionator gmail.com>  
wrote:

 Is there a thing like C's exit() for a D program? Is
 simply using C's function good enough?

Yes, it will work. Note that it does not gracefully shut down a process. Anything outside the process that is left in an intermediate state will not be cleaned up. For instance, if you created a lock file, it will remain. But in general, it's safe to use, the OS will clean up the memory and open handles, etc. -Steve
Dec 06 2010
parent Adam Ruppe <destructionator gmail.com> writes:
Thanks, everyone. I wasn't using any resources that
needed explicit cleanup (no scope exits etc) so I just
used the C exit and it worked well.
Dec 06 2010
prev sibling next sibling parent spir <denis.spir gmail.com> writes:
On Mon, 6 Dec 2010 19:11:59 +0000 (UTC)
Adam Ruppe <destructionator gmail.com> wrote:

 Is there a thing like C's exit() for a D program? Is
 simply using C's function good enough?

I use: import core.stdc.stdlib : exit; // debug tool func void stop () {exit(0);} denis -- -- -- -- -- -- -- vit esse estrany =E2=98=A3 spir.wikidot.com
Dec 06 2010
prev sibling parent Stanislav Blinov <blinov loniir.ru> writes:
06.12.2010 22:11, Adam Ruppe пишет:
 Is there a thing like C's exit() for a D program? Is
 simply using C's function good enough?

Dec 07 2010