PERFORCE change 102852 for review
Roman Divacky
rdivacky at FreeBSD.org
Mon Jul 31 15:20:32 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=102852
Change 102852 by rdivacky at rdivacky_witten on 2006/07/31 15:20:02
Implementation of exit_group() syscall. This might be changed later (the way I kill the
processes).
Affected files ...
.. //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux.h#14 edit
.. //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_machdep.c#27 edit
Differences ...
==== //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux.h#14 (text+ko) ====
@@ -783,6 +783,8 @@
struct linux_emuldata_shared {
int refs;
pid_t group_pid;
+
+ LIST_HEAD(, linux_emuldata) threads; /* head of list of linux threads */
};
/* modeled after similar structure in NetBSD
@@ -797,6 +799,8 @@
struct linux_emuldata_shared *shared;
SLIST_ENTRY(linux_emuldata) emuldatas;
+
+ LIST_ENTRY(linux_emuldata) threads; /* list of linux threads */
};
#define EMUL_RLOCK(l) rw_rlock(l)
==== //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_machdep.c#27 (text+ko) ====
@@ -44,6 +44,7 @@
#include <sys/syscallsubr.h>
#include <sys/sysproto.h>
#include <sys/unistd.h>
+#include <sys/wait.h>
#include <machine/frame.h>
#include <machine/psl.h>
@@ -1184,12 +1185,16 @@
em->shared = s;
s->refs = 1;
s->group_pid = child;
+
+ LIST_INIT(&s->threads);
}
}
- if (child != 0)
+
+ if (child != 0) {
+ LIST_INSERT_HEAD(&em->shared->threads, em, threads);
EMUL_WUNLOCK(&emul_lock);
- else
+ } else
EMUL_RUNLOCK(&emul_lock);
@@ -1249,6 +1254,7 @@
* will exit on different cpus etc.
*/
EMUL_WLOCK(&emul_lock);
+ LIST_REMOVE(em, threads);
SLIST_REMOVE(&emuldata_head, em, linux_emuldata, emuldatas);
EMUL_WUNLOCK(&emul_lock);
@@ -1344,3 +1350,46 @@
EMUL_RUNLOCK(&emul_lock);
return 0;
}
+
+int
+linux_exit_group(struct thread *td, struct linux_exit_group_args *args)
+{
+ struct linux_emuldata *em, *td_em;
+ struct proc *sp;
+ struct kill_args ka;
+ int i = 0;
+
+ td_em = em_find(td->td_proc->p_pid, EMUL_UNLOCKED);
+
+ if (td_em == NULL) {
+#ifdef DEBUG
+ printf(LMSG("we didnt find emuldata in exit_group."));
+#endif
+ return (0);
+ }
+
+ LIST_FOREACH(em, &td_em->shared->threads, threads) {
+ if (i++ > 10)
+ break;
+
+ if (em->pid == td_em->pid)
+ continue;
+
+ sp = pfind(em->pid);
+ PROC_UNLOCK(sp);
+#ifdef DEBUG
+ printf(LMSG("linux_sys_exit_group: kill PID %d\n"), em->pid);
+#endif
+ ka.pid = em->pid;
+ ka.signum = SIGKILL;
+ /* XXX: ehm? */
+ kill(FIRST_THREAD_IN_PROC(sp), &ka);
+
+ }
+
+ EMUL_RUNLOCK(&emul_lock);
+
+ exit1(td, W_EXITCODE(args->error_code,0));
+
+ return (0);
+}
More information about the p4-projects
mailing list