标题: 无法回收的僵尸进程
http://scz.617.cn/unix/201511041359.txt
zyh 2015-11-04 13:59
通常情况下父进程结束后,僵尸进程会被init回收。但是可能出现以下情况:
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD ... 0 Z test 2885 1 0 80 0 - 0 exit Aug11 ? 00:10:38 [adb] ...
2885的父进程已经是init,但它仍保持为僵尸进程。这是因为该进程还有一个内核态 的线程:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND ... test 2885 0.0 0.0 0 0 ? - Aug11 10:38 [adb] test - 0.0 - - - - Zl Aug11 0:00 - test - 0.0 - - - - Dl Aug11 10:38 - ...
STAT列的Dl表示"uninterruptible sleep state",这个线程等待在内核态,并且不 接受任何中断,包括SIGKILL。
用"magic SysRq key"可以看到线程的调用栈:
... [7369283.509835] Call Trace: [7369283.509837] [] schedule+0x3f/0x60 [7369283.509840] [] rpm_resume+0x17e/0x690 [7369283.509842] [] ? add_wait_queue+0x60/0x60 [7369283.509844] [] __pm_runtime_resume+0x5c/0x90 [7369283.509847] [] usb_autoresume_device+0x29/0x60 [7369283.509849] [] usbdev_open+0x11b/0x250 [7369283.509852] [] chrdev_open+0xd9/0x250 [7369283.509854] [] __dentry_open+0x2b0/0x380 [7369283.509856] [] ? cdev_put+0x30/0x30 [7369283.509859] [] ? security_inode_permission+0x1c/0x30 [7369283.509862] [] ? inode_permission+0x4a/0x110 [7369283.509863] [] vfs_open+0x3d/0x40 [7369283.509865] [] nameidata_to_filp+0x40/0x50 [7369283.509867] [] do_last+0x3f8/0x730 [7369283.509869] [] path_openat+0xd1/0x3f0 [7369283.509871] [] ? lock_hrtimer_base.isra.24+0x30/0x60 [7369283.509873] [] ? hrtimer_try_to_cancel+0x50/0xc0 [7369283.509876] [] do_filp_open+0x42/0xa0 [7369283.509878] [] ? strncpy_from_user+0x31/0x40 [7369283.509880] [] ? do_getname+0x10a/0x180 [7369283.509882] [] ? _raw_spin_lock+0xe/0x20 [7369283.509885] [] ? alloc_fd+0xf7/0x150 [7369283.509886] [] do_sys_open+0xf8/0x240 [7369283.509889] [] compat_sys_open+0x1a/0x20 [7369283.509891] [] sysenter_dispatch+0x7/0x2e ...
这里似乎在等待某个USB设备上的文件,然而本机并未接入USB存储设备。所以,能做 的只有重启了。