terminate(): clean-up and formatting
This commit is contained in:
@@ -784,8 +784,7 @@ SYSCALL_DECLARE(waitid)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void terminate(int rc, int sig)
|
||||||
terminate(int rc, int sig)
|
|
||||||
{
|
{
|
||||||
struct resource_set *resource_set = cpu_local_var(resource_set);
|
struct resource_set *resource_set = cpu_local_var(resource_set);
|
||||||
struct thread *mythread = cpu_local_var(current);
|
struct thread *mythread = cpu_local_var(current);
|
||||||
@@ -808,6 +807,7 @@ terminate(int rc, int sig)
|
|||||||
// sync perf info
|
// sync perf info
|
||||||
if (proc->monitoring_event)
|
if (proc->monitoring_event)
|
||||||
sync_child_event(proc->monitoring_event);
|
sync_child_event(proc->monitoring_event);
|
||||||
|
|
||||||
// clean up threads
|
// clean up threads
|
||||||
mcs_rwlock_reader_lock(&proc->threads_lock, &lock); // conflict clone
|
mcs_rwlock_reader_lock(&proc->threads_lock, &lock); // conflict clone
|
||||||
mcs_rwlock_writer_lock_noirq(&proc->update_lock, &updatelock);
|
mcs_rwlock_writer_lock_noirq(&proc->update_lock, &updatelock);
|
||||||
@@ -822,6 +822,7 @@ terminate(int rc, int sig)
|
|||||||
// no return
|
// no return
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
exit_status = mythread->exit_status = ((rc & 0x00ff) << 8) | (sig & 0xff);
|
exit_status = mythread->exit_status = ((rc & 0x00ff) << 8) | (sig & 0xff);
|
||||||
proc->status = PS_EXITED;
|
proc->status = PS_EXITED;
|
||||||
mcs_rwlock_writer_unlock_noirq(&proc->update_lock, &updatelock);
|
mcs_rwlock_writer_unlock_noirq(&proc->update_lock, &updatelock);
|
||||||
@@ -836,6 +837,7 @@ terminate(int rc, int sig)
|
|||||||
list_for_each_entry(thread, &proc->threads_list, siblings_list) {
|
list_for_each_entry(thread, &proc->threads_list, siblings_list) {
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n) {
|
if (n) {
|
||||||
ids = kmalloc(sizeof(int) * n, IHK_MC_AP_NOWAIT);
|
ids = kmalloc(sizeof(int) * n, IHK_MC_AP_NOWAIT);
|
||||||
i = 0;
|
i = 0;
|
||||||
@@ -849,6 +851,7 @@ terminate(int rc, int sig)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mcs_rwlock_reader_unlock(&proc->threads_lock, &lock);
|
mcs_rwlock_reader_unlock(&proc->threads_lock, &lock);
|
||||||
|
|
||||||
if (ids) {
|
if (ids) {
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
do_kill(mythread, proc->pid, ids[i], SIGKILL, NULL, 0);
|
do_kill(mythread, proc->pid, ids[i], SIGKILL, NULL, 0);
|
||||||
@@ -885,9 +888,11 @@ terminate(int rc, int sig)
|
|||||||
if (child->ptrace & PT_TRACED)
|
if (child->ptrace & PT_TRACED)
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n) {
|
if (n) {
|
||||||
ids = kmalloc(sizeof(int) * n, IHK_MC_AP_NOWAIT);
|
ids = kmalloc(sizeof(int) * n, IHK_MC_AP_NOWAIT);
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
if (ids) {
|
if (ids) {
|
||||||
list_for_each_entry(child, &proc->children_list, siblings_list) {
|
list_for_each_entry(child, &proc->children_list, siblings_list) {
|
||||||
if (child->ptrace & PT_TRACED) {
|
if (child->ptrace & PT_TRACED) {
|
||||||
@@ -898,11 +903,13 @@ terminate(int rc, int sig)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mcs_rwlock_reader_unlock(&proc->children_lock, &lock);
|
mcs_rwlock_reader_unlock(&proc->children_lock, &lock);
|
||||||
|
|
||||||
if (ids) {
|
if (ids) {
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
ptrace_detach(ids[i], 0);
|
ptrace_detach(ids[i], 0);
|
||||||
}
|
}
|
||||||
kfree(ids);
|
kfree(ids);
|
||||||
|
ids = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!list_empty(&proc->children_list)) {
|
if (!list_empty(&proc->children_list)) {
|
||||||
@@ -916,6 +923,7 @@ terminate(int rc, int sig)
|
|||||||
int free_child = 0;
|
int free_child = 0;
|
||||||
mcs_rwlock_writer_lock_noirq(&child->update_lock,
|
mcs_rwlock_writer_lock_noirq(&child->update_lock,
|
||||||
&updatelock);
|
&updatelock);
|
||||||
|
|
||||||
if (child->ppid_parent == proc &&
|
if (child->ppid_parent == proc &&
|
||||||
child->status == PS_ZOMBIE) {
|
child->status == PS_ZOMBIE) {
|
||||||
list_del(&child->hash_list);
|
list_del(&child->hash_list);
|
||||||
@@ -944,8 +952,10 @@ terminate(int rc, int sig)
|
|||||||
mcs_rwlock_writer_unlock_noirq(&proc->children_lock,
|
mcs_rwlock_writer_unlock_noirq(&proc->children_lock,
|
||||||
&childlock);
|
&childlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
mcs_rwlock_writer_unlock_noirq(&child->update_lock,
|
mcs_rwlock_writer_unlock_noirq(&child->update_lock,
|
||||||
&updatelock);
|
&updatelock);
|
||||||
|
|
||||||
if (free_child)
|
if (free_child)
|
||||||
kfree(child);
|
kfree(child);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user