When a multi-threaded init exits and the initial thread is not the last thread to exit the initial thread hangs around as a zombie until the last thread exits. In that case zap_pid_ns_processes needs to wait until there are only 2 hashed pids in the pid namespace not one. v2. Replace thread_pid_vnr(me) == 1 with the test thread_group_leader(me) as suggested by Oleg.
Unified · Split
| @@ -181,6 +181,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns) · 180 unmodified lines | ||
| 181 | 181 | int nr; |
| 182 | 182 | int rc; |
| 183 | 183 | struct task_struct *task, *me = current; |
| 184 | + int init_pids = thread_group_leader(me) ? 1 : 2; | |
| 184 | 185 | |
| 185 | 186 | /* Don't allow any more processes into the pid namespace */ |
| 186 | 187 | disable_pid_allocation(pid_ns); |
| @@ -230,7 +231,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns) · 43 unmodified lines | ||
| 230 | 231 | */ |
| 231 | 232 | for (;;) { |
| 232 | 233 | set_current_state(TASK_UNINTERRUPTIBLE); |
| 233 | − if (pid_ns->nr_hashed == 1) | |
| 234 | + if (pid_ns->nr_hashed == init_pids) | |
| 234 | 235 | break; |
| 235 | 236 | schedule(); |
| 236 | 237 | } |