aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/pid.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-11-08 16:04:01 +0000
committerrsc <devnull@localhost>2004-11-08 16:04:01 +0000
commit24f4e66b12cf0501d0f239ade10b2963f46e6755 (patch)
tree6fb79980edf83c07bba66b7303dde8874c6d7e33 /src/libthread/pid.c
parentcf4f3eafc6016ccdb57773215dcdd5ebac95c07d (diff)
downloadplan9port-24f4e66b12cf0501d0f239ade10b2963f46e6755.tar.gz
plan9port-24f4e66b12cf0501d0f239ade10b2963f46e6755.tar.bz2
plan9port-24f4e66b12cf0501d0f239ade10b2963f46e6755.zip
still more files
Diffstat (limited to 'src/libthread/pid.c')
-rw-r--r--src/libthread/pid.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libthread/pid.c b/src/libthread/pid.c
new file mode 100644
index 00000000..bbc7dbbf
--- /dev/null
+++ b/src/libthread/pid.c
@@ -0,0 +1,25 @@
+ mypid = getpid();
+
+ /*
+ * signal others.
+ * copying all the pids first avoids other thread's
+ * teardown procedures getting in the way.
+ */
+ lock(&_threadpq.lock);
+ npid = 0;
+ for(p=_threadpq.head; p; p=p->next)
+ npid++;
+ pid = _threadmalloc(npid*sizeof(pid[0]), 0);
+ npid = 0;
+ for(p = _threadpq.head; p; p=p->next)
+ pid[npid++] = p->pid;
+ unlock(&_threadpq.lock);
+ for(i=0; i<npid; i++){
+ _threaddebug(DBGSCHED, "threadexitsall kill %d", pid[i]);
+ if(pid[i]==0 || pid[i]==-1)
+ fprint(2, "bad pid in threadexitsall: %d\n", pid[i]);
+ else if(pid[i] != mypid){
+ kill(pid[i], SIGTERM);
+ }
+ }
+