Re: D daemon GC?

2014-08-31 Thread JD via Digitalmars-d-learn
Last snippet works for me, dots get printed to the logfile as expected. Ok, it works now. Using the recommended _Exit() function with DMD 2.066 on Linux. Thanks you all for your help! Best regards, Jeroen

Re: D daemon GC?

2014-08-31 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 31 August 2014 at 09:02:55 UTC, JD wrote: Last snippet works for me, dots get printed to the logfile as expected. Ok, it works now. Using the recommended _Exit() function with DMD 2.066 on Linux. Thanks you all for your help! Best regards, Jeroen On a side note, i've created

Re: D daemon GC?

2014-08-31 Thread Raphaƫl Jakse via Digitalmars-d-learn
On 30/08/2014 19:09, JD wrote: My questions: 1. Are there any special considerations w.r.t. the GC after using fork()? Or must it be disabled? 2. Is it allowed to use stdlib's exit() without cleaning up after the runtime (as a normal end of program probably does)? Or is there a safe D exit()?

D daemon GC?

2014-08-30 Thread JD via Digitalmars-d-learn
Hi all, I tried to write a Linux daemon in D 2.065 (by translating one in C we use at work). My basic skeleton works well. But as soon as I start allocating memory it crashed with several 'core.exception.InvalidMemoryOperationError's. My questions: 1. Are there any special considerations

Re: D daemon GC?

2014-08-30 Thread safety0ff via Digitalmars-d-learn
On Saturday, 30 August 2014 at 17:09:41 UTC, JD wrote: Hi all, I tried to write a Linux daemon in D 2.065 (by translating one in C we use at work). My basic skeleton works well. But as soon as I start allocating memory it crashed with several 'core.exception.InvalidMemoryOperationError's.

Re: D daemon GC?

2014-08-30 Thread Dicebot via Digitalmars-d-learn
I had similar issues. Thing is D compiler places runtime cleanup initialization code into binary constructor sections (fini_array) which is needed to support shared libraries properly. But the same code gets triggered when you run `exit` in a fork resulting in attempt to terminate other

Re: D daemon GC?

2014-08-30 Thread via Digitalmars-d-learn
On Saturday, 30 August 2014 at 17:36:41 UTC, safety0ff wrote: On Saturday, 30 August 2014 at 17:09:41 UTC, JD wrote: Hi all, I tried to write a Linux daemon in D 2.065 (by translating one in C we use at work). My basic skeleton works well. But as soon as I start allocating memory it crashed

Re: D daemon GC?

2014-08-30 Thread JD via Digitalmars-d-learn
Oops, I accidentally commented out the line allocating the memory in the example code... sorry. // this statement causes core.exception.InvalidMemoryOperationError // auto t = new char[4096]; should read: // this statement causes core.exception.InvalidMemoryOperationError

Re: D daemon GC?

2014-08-30 Thread Israel via Digitalmars-d-learn
On Saturday, 30 August 2014 at 17:09:41 UTC, JD wrote: Hi all, Or is there a safe D exit()? I always wondered why D doesnt have this. I tried searching google and could not find a definitive answer except interfacing with C...

Re: D daemon GC?

2014-08-30 Thread JD via Digitalmars-d-learn
I can already say that it nevertheless works with DMD git. Will test soon with Digger, unfortunately Bitbucket is currently down, and Digger depends on it. In the meantime I installed DMD 2.066 and I changed the exit() function after the fork as Dicebot suggested. Unfortunately I got the

Re: D daemon GC?

2014-08-30 Thread ketmar via Digitalmars-d-learn
On Sat, 30 Aug 2014 19:20:44 + Israel via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Or is there a safe D exit()? I always wondered why D doesnt have this. the idiomatic way is to throw an exception which can be catched in main() (and then we can `return 1` from main() or

Re: D daemon GC?

2014-08-30 Thread via Digitalmars-d-learn
On Saturday, 30 August 2014 at 19:20:39 UTC, JD wrote: I can already say that it nevertheless works with DMD git. Will test soon with Digger, unfortunately Bitbucket is currently down, and Digger depends on it. In the meantime I installed DMD 2.066 and I changed the exit() function after the

Re: D daemon GC?

2014-08-30 Thread JD via Digitalmars-d-learn
I tested it again, and it works fine in both 2.065 and 2.066. Be aware that you should comment out: // close(STDOUT_FILENO); // close(STDERR_FILENO); A daemon normally detaches itself from the terminal by closing the STD* files. All D's runtime exception messages will not appear in

Re: D daemon GC?

2014-08-30 Thread Dicebot via Digitalmars-d-learn
On Saturday, 30 August 2014 at 19:52:24 UTC, JD wrote: I tested it again, and it works fine in both 2.065 and 2.066. Be aware that you should comment out: // close(STDOUT_FILENO); // close(STDERR_FILENO); A daemon normally detaches itself from the terminal by closing the STD*