Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
December 06, 2010 How to exit a process? | ||||
---|---|---|---|---|
| ||||
Is there a thing like C's exit() for a D program? Is simply using C's function good enough? |
December 06, 2010 Re: How to exit a process? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam Ruppe | 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?
>
|
December 06, 2010 Re: How to exit a process? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam Ruppe | 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
|
December 06, 2010 Re: How to exit a process? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam Ruppe | 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 ☣
spir.wikidot.com
|
December 07, 2010 Re: How to exit a process? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | 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. |
December 07, 2010 Re: How to exit a process? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam Ruppe | 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? > Also take a look at core.runtime.Runtime.terminate() |
Copyright © 1999-2021 by the D Language Foundation