On Mon, 26 Mar 2012 17:10:34 +0200, Timon Gehr <timon.g...@gmx.ch> wrote:

On 03/26/2012 11:55 AM, simendsjo wrote:
It seems threads created in the c library is totally unknown to D. How
can I make D aware of these threads when there is no library support for
it?

You may be looking for this:
http://dlang.org/phobos/core_thread.html#thread_attachThis

Thanks, but I tried that too and couldn't get it to work.

I added the following:

extern(C) handler()
{
synchronized // needed here to avoid the GC to collect while attaching thread?
    {
        if(!Thread.getThis()) // thread unknown to D
        {
            thread_attachThis();
            assert(Thread.getThis()); // now D knows about it
        }
    }
    GC.collect(); // still segfaults
}

Actually, using attachThis segfaults GC.collect() outside the thread handling code too.

Reply via email to