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