Hangs on toStringZ()

Nemanja Boric via Digitalmars-d digitalmars-d at puremagic.com
Wed Dec 28 03:30:22 PST 2016


On Wednesday, 28 December 2016 at 11:21:34 UTC, Nemanja Boric 
wrote:
> On Tuesday, 27 December 2016 at 17:27:14 UTC, unDEFER wrote:
>> Hello I have very simple line with exec-command:
>>
>> execl("/bin/bash".toStringz(), "/bin/bash".toStringz(), 
>> "-c".toStringz(), command.toStringz(), null);
>>
>> [...]
>
> Just a note here, string literals are already 0 terminated, so 
> you don't need `toStringz` there.

Ah, I just saw Stefan already made this remark, sorry.

Given that you're in a forked process, it could be that you've 
just got your GC in a broken state (internal was locked prior to 
forking, and now you can't get the GC ever, since there's nothing 
to unlock it.

What you should do is following:

1. Allocate all needed data, convert all D strings into C 
strings, etc.
2. fork
3. exec immediately, not using anything from standard library 
between 2 and 3.


More information about the Digitalmars-d mailing list