- 論壇徽章:
- 11
|
本帖最后由 zylthinking 于 2011-12-07 15:27 編輯
確定。你是怎麼想的?
Mr_Yao 發(fā)表于 2011-12-07 14:50 ![]()
所謂僵尸進程, 其實就是 SIGCHILD 沒有被父進程處理的進程, SIGCHILD 被處理只有在中斷, 異常, 及系統(tǒng)調(diào)用返回時;
首先異常不可能發(fā)生; 因為異常發(fā)生在用戶空間; 除非是頁面錯誤;
中斷可不太可能, 因為 sleep 時已經(jīng)是不在運行列表中了, 中斷借助的是當(dāng)前進程, 因此就算處理SIGCHILD也不會是 sleep 中的進程的SIGCHILD
剩下的系統(tǒng)調(diào)用就奇怪了, 因為這里正好命中, 那么在 sleep 返回后, 應(yīng)該已經(jīng)處理了 sigchild 的。- 205ENTRY(ret_from_sys_call)
- 206#ifdef CONFIG_SMP
- 207 movl processor(%ebx),%eax
- 208 shll $CONFIG_X86_L1_CACHE_SHIFT,%eax
- 209 movl SYMBOL_NAME(irq_stat)(,%eax),%ecx # softirq_active
- 210 testl SYMBOL_NAME(irq_stat)+4(,%eax),%ecx # softirq_mask
- 211#else
- 212 movl SYMBOL_NAME(irq_stat),%ecx # softirq_active
- 213 testl SYMBOL_NAME(irq_stat)+4,%ecx # softirq_mask
- 214#endif
- 215 jne handle_softirq
- 216
- 217ret_with_reschedule:
- 218 cmpl $0,need_resched(%ebx)
- 219 jne reschedule
- 220 cmpl $0,sigpending(%ebx) ----------------這里
- 221 jne signal_return
- 222restore_all:
- 223 RESTORE_ALL
- 224
- 225 ALIGN
- 226signal_return:
- 227 sti # we can get here from an interrupt handler
- 228 testl $(VM_MASK),EFLAGS(%esp)
- 229 movl %esp,%eax
- 230 jne v86_signal_return
- 231 xorl %edx,%edx
- 232 call SYMBOL_NAME(do_signal) --------------這里
- 233 jmp restore_all
- 234
- 235 ALIGN
復(fù)制代碼- 536
-
- 584int do_signal(struct pt_regs *regs, sigset_t *oldset)
- 585{
- 586 siginfo_t info;
- 587 struct k_sigaction *ka;
- .......................................
- 643 ka = ¤t->sig->action[signr-1];
- 644 if (ka->sa.sa_handler == SIG_IGN) {
- 645 if (signr != SIGCHLD)
- 646 continue;
- 647 /* Check for SIGCHLD: it's special. */
- 648 while (sys_wait4(-1, NULL, WNOHANG, NULL) > 0) ------------------這里
- 649 /* nothing */;
- 650 continue;
- 651 }
- 652
- ...........................................
- 715 return 0;
- 716}
- 717
復(fù)制代碼 那為什么在其后的 ps 中, 會照樣找到一個 zombie 的子進程呢 |
|