diff options
Diffstat (limited to 'concurrency.c')
-rw-r--r-- | concurrency.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/concurrency.c b/concurrency.c index d04876d..81ff7b1 100644 --- a/concurrency.c +++ b/concurrency.c @@ -117,9 +117,18 @@ newprocfn(void *data) ThreadData *td = newthreaddata(); void **tdptr = threaddata(); *tdptr = td; - int done = 1; - send(sp->setupdone, &done); - runfunc(sp->func, sp->left, sp->right); + ErrorGuard *eg = newerrorguard(mkscalarint(0), nil); /* make a catch-all error guard */ + if(setjmp(eg->jmp)){ + print("Thread %d: %S%S%S\n", + threadid(), + errorstr(td->lasterror), + (td->lasterror && td->lasterrormsg) ? L": " : L"", + td->lasterrormsg ? td->lasterrormsg : L""); + }else{ + int done = 1; + send(sp->setupdone, &done); + runfunc(sp->func, sp->left, sp->right); + } lock(&threadlock); /* TODO remove thread */ unlock(&threadlock); |