changeset: 10252:37d917e78e64 tag: tip user: Severin Wischmann date: Mon Jul 07 09:45:47 2014 +0200 summary: Implementation of exit_group on X86. diff -r 878f2f30b12d -r 37d917e78e64 src/sim/syscall_emul.cc --- a/src/sim/syscall_emul.cc Wed Jul 02 13:19:13 2014 -0400 +++ b/src/sim/syscall_emul.cc Mon Jul 07 09:45:47 2014 +0200 @@ -132,11 +132,23 @@ exitGroupFunc(SyscallDesc *desc, int callnum, LiveProcess *process, ThreadContext *tc) { - // really should just halt all thread contexts belonging to this - // process in case there's another process running... - int index = 0; - exitSimLoop("target called exit()", - process->getSyscallArg(tc, index) & 0xff); + if (process->system->numRunningContexts() == 1) { + // Last running context... exit simulator + int index = 0; + exitSimLoop("target called exit()", + process->getSyscallArg(tc, index) & 0xff); + } else { + // other running processes... halt all threads belonging to this one + for (auto i: process->contextIds) { + process->system->getThreadContext(i)->halt(); + } + if (!process->system->numRunningContexts()) { + // all remaining threads belonged to this process... exit simulator + int index = 0; + exitSimLoop("target called exit()", + process->getSyscallArg(tc, index) & 0xff); + } + } return 1; }