Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

exit: change zap_other_threads() to count sub-threads

Change zap_other_threads() to return the number of other sub-threads found
on ->thread_group list.

Other changes are cosmetic:

- change the code to use while_each_thread() helper

- remove the obsolete comment about SIGKILL/SIGSTOP

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Roland McGrath <roland@redhat.com>
Cc: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Oleg Nesterov and committed by
Linus Torvalds
09faef11 9c339168

+10 -9
+1 -1
include/linux/sched.h
··· 2036 2036 extern void __wake_up_parent(struct task_struct *p, struct task_struct *parent); 2037 2037 extern void force_sig(int, struct task_struct *); 2038 2038 extern int send_sig(int, struct task_struct *, int); 2039 - extern void zap_other_threads(struct task_struct *p); 2039 + extern int zap_other_threads(struct task_struct *p); 2040 2040 extern struct sigqueue *sigqueue_alloc(void); 2041 2041 extern void sigqueue_free(struct sigqueue *); 2042 2042 extern int send_sigqueue(struct sigqueue *, struct task_struct *, int group);
+9 -8
kernel/signal.c
··· 1085 1085 /* 1086 1086 * Nuke all other threads in the group. 1087 1087 */ 1088 - void zap_other_threads(struct task_struct *p) 1088 + int zap_other_threads(struct task_struct *p) 1089 1089 { 1090 - struct task_struct *t; 1090 + struct task_struct *t = p; 1091 + int count = 0; 1091 1092 1092 1093 p->signal->group_stop_count = 0; 1093 1094 1094 - for (t = next_thread(p); t != p; t = next_thread(t)) { 1095 - /* 1096 - * Don't bother with already dead threads 1097 - */ 1095 + while_each_thread(p, t) { 1096 + count++; 1097 + 1098 + /* Don't bother with already dead threads */ 1098 1099 if (t->exit_state) 1099 1100 continue; 1100 - 1101 - /* SIGKILL will be handled before any pending SIGSTOP */ 1102 1101 sigaddset(&t->pending.signal, SIGKILL); 1103 1102 signal_wake_up(t, 1); 1104 1103 } 1104 + 1105 + return count; 1105 1106 } 1106 1107 1107 1108 struct sighand_struct *lock_task_sighand(struct task_struct *tsk, unsigned long *flags)