On Thursday, 27 October 2016 at 13:37:29 UTC, Steven Schveighoffer wrote:

Hm... what about:

import std.traits: Parameters;

auto mySpawn(F)(F func, Parameters!F params)
{
    static auto callIt(F func, Parameters!F params)
    {
        try
        {
            return func(params);
        }
        catch(Throwable t)
        {
            // print the exception/error, e.g.:
            import std.writeln;
            writeln(e.toString());
            // terminate program
            import core.stdc.stdlib : exit;
            exit(1);
        }
    }

    return spawn(&callIt, func, params);
}

void main()
{
    auto tID = mySpawn(&func);
    ...
}

-Steve

I found the solution which works with dmd and ldc2:

...
import core.stdc.stdlib: _Exit;
_Exit(exitcode);
...

Reply via email to