From 803292c631c8e80a0596a011a901e72c8e0e0edc Mon Sep 17 00:00:00 2001 From: rsc Date: Tue, 18 Jan 2005 20:53:12 +0000 Subject: proccreate race --- src/libthread/thread.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libthread/thread.c b/src/libthread/thread.c index b154ce6e..ff22bbaa 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -171,13 +171,15 @@ threadcreate(void (*fn)(void*), void *arg, uint stack) int proccreate(void (*fn)(void*), void *arg, uint stack) { + int id; _Thread *t; Proc *p; p = procalloc(); t = _threadcreate(p, fn, arg, stack); + id = t->id; /* t might be freed after _procstart */ _procstart(p, scheduler); - return t->id; + return id; } void -- cgit v1.2.3