2 #include "threadimpl.h"
4 char *_threadexitsallstatus;
5 Channel *_threadwaitchan;
8 threadexits(char *exitstr)
16 _threaddebug(DBGSCHED, "threadexits %s", exitstr);
19 utfecpy(p->exitstr, p->exitstr+ERRMAX, exitstr);
24 threadexitsall(char *exitstr)
30 _threaddebug(DBGSCHED, "threadexitsall %s", exitstr);
33 _threadexitsallstatus = exitstr;
34 _threaddebug(DBGSCHED, "_threadexitsallstatus set to %p", _threadexitsallstatus);
35 mypid = _threadgetpid();
39 * copying all the pids first avoids other thread's
40 * teardown procedures getting in the way.
42 lock(&_threadpq.lock);
44 for(p=_threadpq.head; p; p=p->next)
46 pid = _threadmalloc(npid*sizeof(pid[0]), 0);
48 for(p = _threadpq.head; p; p=p->next)
50 unlock(&_threadpq.lock);
51 for(i=0; i<npid; i++){
52 _threaddebug(DBGSCHED, "threadexitsall kill %d", pid[i]);
53 if(pid[i]==0 || pid[i]==-1)
54 fprint(2, "bad pid in threadexitsall: %d\n", pid[i]);
55 else if(pid[i] != mypid)
56 kill(pid[i], SIGTERM);
66 if(_threadwaitchan==nil)
67 _threadwaitchan = chancreate(sizeof(Waitmsg*), 16);
68 return _threadwaitchan;