3 #include "threadimpl.h"
5 char *_threadexitsallstatus;
6 Channel *_threadwaitchan;
9 threadexits(char *exitstr)
19 _threaddebug(DBGSCHED, "threadexits %s", exitstr);
22 utfecpy(p->exitstr, p->exitstr+ERRMAX, exitstr);
27 threadexitsall(char *exitstr)
33 _threaddebug(DBGSCHED, "threadexitsall %s", exitstr);
36 _threadexitsallstatus = exitstr;
37 _threaddebug(DBGSCHED, "_threadexitsallstatus set to %p", _threadexitsallstatus);
38 mypid = _threadgetpid();
42 * copying all the pids first avoids other thread's
43 * teardown procedures getting in the way.
45 lock(&_threadpq.lock);
47 for(p=_threadpq.head; p; p=p->next)
49 pid = _threadmalloc(npid*sizeof(pid[0]), 0);
51 for(p = _threadpq.head; p; p=p->next)
53 unlock(&_threadpq.lock);
54 for(i=0; i<npid; i++){
55 _threaddebug(DBGSCHED, "threadexitsall kill %d", pid[i]);
56 if(pid[i]==0 || pid[i]==-1)
57 fprint(2, "bad pid in threadexitsall: %d\n", pid[i]);
58 else if(pid[i] != mypid)
59 kill(pid[i], SIGTERM);
69 if(_threadwaitchan==nil)
70 _threadwaitchan = chancreate(sizeof(Waitmsg*), 16);
71 return _threadwaitchan;