Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_exit.c
Show First 20 Lines • Show All 385 Lines • ▼ Show 20 Lines | if (p->p_leader->p_peers != NULL) { | ||||
q = q->p_peers; | q = q->p_peers; | ||||
q->p_peers = p->p_peers; | q->p_peers = p->p_peers; | ||||
wakeup(p->p_leader); | wakeup(p->p_leader); | ||||
} | } | ||||
mtx_unlock(&ppeers_lock); | mtx_unlock(&ppeers_lock); | ||||
} | } | ||||
vmspace_exit(td); | vmspace_exit(td); | ||||
killjobc(); | |||||
(void)acct_process(td); | (void)acct_process(td); | ||||
#ifdef KTRACE | #ifdef KTRACE | ||||
ktrprocexit(td); | ktrprocexit(td); | ||||
#endif | #endif | ||||
/* | /* | ||||
* Release reference to text vnode | * Release reference to text vnode | ||||
*/ | */ | ||||
Show All 26 Lines | #endif | ||||
sx_xlock(&allproc_lock); | sx_xlock(&allproc_lock); | ||||
LIST_REMOVE(p, p_list); | LIST_REMOVE(p, p_list); | ||||
sx_xunlock(&allproc_lock); | sx_xunlock(&allproc_lock); | ||||
sx_xlock(&proctree_lock); | sx_xlock(&proctree_lock); | ||||
PROC_LOCK(p); | PROC_LOCK(p); | ||||
p->p_flag &= ~(P_TRACED | P_PPWAIT | P_PPTRACE); | p->p_flag &= ~(P_TRACED | P_PPWAIT | P_PPTRACE); | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
jilles: This call may unlock and relock `proctree_lock`, which appears safe at this time but restricts… | |||||
Done Inline ActionsYes, with the current code there was a race when short-circuiting killjobc, since parent can change its group after or during the check. With this code organization, race should be gone. I tried to avoid dropping the lock by postponing revoke of the ctty devfs vnode after proctree_lock is dropped, but then it comes in interlock with process lock and then process spinlock till the thread is finally removed from CPU. I do not think it is safe to postpone revoke after exit(2) is signalling children. So I do not see a better code organization. But I added a comment there. kib: Yes, with the current code there was a race when short-circuiting killjobc, since parent can… | |||||
/* | |||||
* killjobc() might drop and re-acquire proctree_lock to | |||||
* revoke control tty if exiting process was a session leader. | |||||
*/ | |||||
killjobc(); | |||||
/* | /* | ||||
* Reparent all children processes: | * Reparent all children processes: | ||||
* - traced ones to the original parent (or init if we are that parent) | * - traced ones to the original parent (or init if we are that parent) | ||||
* - the rest to init | * - the rest to init | ||||
*/ | */ | ||||
q = LIST_FIRST(&p->p_children); | q = LIST_FIRST(&p->p_children); | ||||
if (q != NULL) /* only need this if any child is S_ZOMB */ | if (q != NULL) /* only need this if any child is S_ZOMB */ | ||||
▲ Show 20 Lines • Show All 931 Lines • Show Last 20 Lines |
This call may unlock and relock proctree_lock, which appears safe at this time but restricts changes that can be made here.