digitalmars.D.learn - exit(1)?
- Shriramana Sharma (7/7) Dec 16 2015 http://dlang.org/phobos/std_getopt.html has a line in an example saying
- Jakob Ovrum (6/12) Dec 16 2015 Ouch, that's not good. `exit` is not a good way to terminate a D
- Jacob Carlborg (5/8) Dec 16 2015 I agree with that, but why don't the runtime register a function with
- Jakob Ovrum (5/7) Dec 17 2015 I think it might be possible, but it doesn't sound trivial. In
- Shriramana Sharma (4/6) Dec 17 2015 https://github.com/D-Programming-Language/phobos/pull/3875
http://dlang.org/phobos/std_getopt.html has a line in an example saying exit(1); Surely this works only if core.stdc.stdlib is imported? Should the example be modified to show the import? And is exit() the canonical way to exit the current process even in D? --
Dec 16 2015
On Thursday, 17 December 2015 at 05:02:50 UTC, Shriramana Sharma wrote:http://dlang.org/phobos/std_getopt.html has a line in an example saying exit(1); Surely this works only if core.stdc.stdlib is imported? Should the example be modified to show the import? And is exit() the canonical way to exit the current process even in D?Ouch, that's not good. `exit` is not a good way to terminate a D program. It doesn't call destructors, including module destructors. The example should be restructured to `return 1;` from `main`.
Dec 16 2015
On 2015-12-17 06:11, Jakob Ovrum wrote:Ouch, that's not good. `exit` is not a good way to terminate a D program. It doesn't call destructors, including module destructors. The example should be restructured to `return 1;` from `main`.I agree with that, but why don't the runtime register a function with "atexit" that cleans up everything? -- /Jacob Carlborg
Dec 16 2015
On Thursday, 17 December 2015 at 07:33:36 UTC, Jacob Carlborg wrote:I agree with that, but why don't the runtime register a function with "atexit" that cleans up everything?I think it might be possible, but it doesn't sound trivial. In particular, all threads and fibers managed by druntime need to have their stacks rewinded.
Dec 17 2015
Jakob Ovrum wrote:The example should be restructured to `return 1;` from `main`.https://github.com/D-Programming-Language/phobos/pull/3875 --
Dec 17 2015