Hangs on toStringZ()
Stefan Koch via Digitalmars-d
digitalmars-d at puremagic.com
Tue Dec 27 09:50:14 PST 2016
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);
>
> [...]
The string is allocated on the gc-ed heap.
And since it's an R value it might get destroyed before execl is
finished.
Assign the result of toStringz to a char* variable and use that
in the call.
More information about the Digitalmars-d
mailing list