Index: sys/miscfs/procfs/procfs_subr.c =================================================================== RCS file: /cvsroot/src/sys/miscfs/procfs/procfs_subr.c,v retrieving revision 1.91 diff -u -p -u -r1.91 procfs_subr.c --- sys/miscfs/procfs/procfs_subr.c 2 Jul 2008 19:49:58 -0000 1.91 +++ sys/miscfs/procfs/procfs_subr.c 5 Sep 2008 13:42:49 -0000 @@ -372,8 +372,17 @@ procfs_rw(v) #undef M2K mutex_enter(p->p_lock); - l = LIST_FIRST(&p->p_lwps); - KASSERT(l != NULL); + LIST_FOREACH(l, &p->p_lwps, l_sibling) { + if (l->l_stat != LSZOMB) + break; + } + /* Process is exiting if no-LWPS or all LWPs are LSZOMB */ + if (l == NULL) { + mutex_exit(p->p_lock); + procfs_proc_unlock(p); + return ESRCH; + } + lwp_addref(l); mutex_exit(p->p_lock); Index: sys/miscfs/procfs/procfs_vnops.c =================================================================== RCS file: /cvsroot/src/sys/miscfs/procfs/procfs_vnops.c,v retrieving revision 1.171 diff -u -p -u -r1.171 procfs_vnops.c --- sys/miscfs/procfs/procfs_vnops.c 5 Sep 2008 13:21:12 -0000 1.171 +++ sys/miscfs/procfs/procfs_vnops.c 5 Sep 2008 13:42:51 -0000 @@ -974,6 +974,7 @@ procfs_lookup(void *v) pid_t pid, vnpid; struct pfsnode *pfs; struct proc *p = NULL; + struct lwp *plwp; int i, error; pfstype type; @@ -1053,23 +1054,33 @@ procfs_lookup(void *v) if (procfs_proc_lock(pfs->pfs_pid, &p, ESRCH) != 0) break; + mutex_enter(p->p_lock); + LIST_FOREACH(plwp, &p->p_lwps, l_sibling) { + if (plwp->l_stat != LSZOMB) + break; + } + /* Process is exiting if no-LWPS or all LWPs are LSZOMB */ + if (plwp == NULL) { + mutex_exit(p->p_lock); + procfs_proc_unlock(p); + return ESRCH; + } + + lwp_addref(plwp); + mutex_exit(p->p_lock); + for (pt = proc_targets, i = 0; i < nproc_targets; pt++, i++) { - struct lwp *plwp; int found; - mutex_enter(p->p_lock); - plwp = LIST_FIRST(&p->p_lwps); - KASSERT(plwp != NULL); - lwp_addref(plwp); - mutex_exit(p->p_lock); found = cnp->cn_namelen == pt->pt_namlen && memcmp(pt->pt_name, pname, cnp->cn_namelen) == 0 && (pt->pt_valid == NULL || (*pt->pt_valid)(plwp, dvp->v_mount)); - lwp_delref(plwp); if (found) break; } + lwp_delref(plwp); + if (i == nproc_targets) { procfs_proc_unlock(p); break;