Re: Hangs on toStringZ()

2016-12-28 Thread unDEFER via Digitalmars-d
On Wednesday, 28 December 2016 at 12:39:46 UTC, Nemanja Boric wrote: Right, nothing wrong with threads, but super tricky to combine it with fork. So, it could be that one of your threads is using GC at the point of the forking, so it keeps the GC locked. Now you fork, and _all your threads

Re: Hangs on toStringZ()

2016-12-28 Thread Nemanja Boric via Digitalmars-d
On Wednesday, 28 December 2016 at 12:30:03 UTC, unDEFER wrote: On Wednesday, 28 December 2016 at 11:32:09 UTC, Nemanja Boric wrote: My other guess is that you're using D threads in your application? Of course I'm using D threads, but with it all is normally. Right, nothing wrong with

Re: Hangs on toStringZ()

2016-12-28 Thread unDEFER via Digitalmars-d
On Wednesday, 28 December 2016 at 11:32:09 UTC, Nemanja Boric wrote: My other guess is that you're using D threads in your application? Of course I'm using D threads, but with it all is normally.

Re: Hangs on toStringZ()

2016-12-28 Thread unDEFER via Digitalmars-d
On Wednesday, 28 December 2016 at 11:30:22 UTC, Nemanja Boric wrote: 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. OK, thank you.. I'm trying it

Re: Hangs on toStringZ()

2016-12-28 Thread Nemanja Boric via Digitalmars-d
On Wednesday, 28 December 2016 at 11:30:22 UTC, Nemanja Boric wrote: 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: [...] Just a note here, string literals are already 0 terminated, so you don't need

Re: Hangs on toStringZ()

2016-12-28 Thread Nemanja Boric via Digitalmars-d
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); [...]

Re: Hangs on toStringZ()

2016-12-28 Thread Nemanja Boric via Digitalmars-d
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

Re: Hangs on toStringZ()

2016-12-27 Thread unDEFER via Digitalmars-d
On Tuesday, 27 December 2016 at 21:33:46 UTC, Marc Schütz wrote: What context are you calling this from? Is this in a signal handler? Or from inside a destructor of a GC-owned object? It is child of my process after fork and before execl. No signal handler, no destructor, no catch-block,

Re: Hangs on toStringZ()

2016-12-27 Thread Marc Schütz via Digitalmars-d
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); And on this line on toStringz my program sometimes hangs. backtrace: (gdb) bt

Re: Hangs on toStringZ()

2016-12-27 Thread unDEFER via Digitalmars-d
The last backtrace shows that it hangs on the line: immutable(char) *bash = "/bin/bash".toStringz();

Re: Hangs on toStringZ()

2016-12-27 Thread Stefan Koch via Digitalmars-d
On Tuesday, 27 December 2016 at 18:22:12 UTC, unDEFER wrote: On Tuesday, 27 December 2016 at 18:01:36 UTC, Stefan Koch wrote: Have you tried assigning it to a variable ? Yes, I have tried, now backtrace of hanged process is: (gdb) bt #0 0x7f4e18260c6d in ?? () #1 0x in

Re: Hangs on toStringZ()

2016-12-27 Thread unDEFER via Digitalmars-d
On Tuesday, 27 December 2016 at 18:01:36 UTC, Stefan Koch wrote: Have you tried assigning it to a variable ? Yes, I have tried, now backtrace of hanged process is: (gdb) bt #0 0x7f4e18260c6d in ?? () #1 0x in ?? ()

Re: Hangs on toStringZ()

2016-12-27 Thread unDEFER via Digitalmars-d
On Tuesday, 27 December 2016 at 17:50:14 UTC, Stefan Koch wrote: 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. But execl not goes to Seg.fault.

Re: Hangs on toStringZ()

2016-12-27 Thread Stefan Koch via Digitalmars-d
On Tuesday, 27 December 2016 at 18:00:11 UTC, unDEFER wrote: On Tuesday, 27 December 2016 at 17:50:14 UTC, Stefan Koch wrote: 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

Re: Hangs on toStringZ()

2016-12-27 Thread Stefan Koch via Digitalmars-d
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

Hangs on toStringZ()

2016-12-27 Thread unDEFER via Digitalmars-d
Hello I have very simple line with exec-command: execl("/bin/bash".toStringz(), "/bin/bash".toStringz(), "-c".toStringz(), command.toStringz(), null); And on this line on toStringz my program sometimes hangs. backtrace: (gdb) bt #0 0x7f3acd535c6d in nanosleep () at