Lines 399-424
procdesc_close(struct file *fp, struct thread *td)
Link Here
|
399 |
PROC_SLOCK(p); |
399 |
PROC_SLOCK(p); |
400 |
proc_reap(curthread, p, NULL, 0); |
400 |
proc_reap(curthread, p, NULL, 0); |
401 |
} else { |
401 |
} else { |
402 |
/* |
402 |
/* we don't need to do the following if we are already |
403 |
* If the process is not yet dead, we need to kill it, |
403 |
* exiting */ |
404 |
* but we can't wait around synchronously for it to go |
404 |
if (!(p->p_flag & P_WEXIT)) { |
405 |
* away, as that path leads to madness (and deadlocks). |
405 |
/* |
406 |
* First, detach the process from its descriptor so that |
406 |
* If the process is not yet dead, we need to |
407 |
* its exit status will be reported normally. |
407 |
* kill it, but we can't wait around |
408 |
*/ |
408 |
* synchronously for it to go away, as that |
409 |
pd->pd_proc = NULL; |
409 |
* path leads to madness (and deadlocks). |
410 |
p->p_procdesc = NULL; |
410 |
* First, detach the process from its |
411 |
procdesc_free(pd); |
411 |
* descriptor so that its exit status will be |
|
|
412 |
* reported normally. |
413 |
*/ |
414 |
pd->pd_proc = NULL; |
415 |
p->p_procdesc = NULL; |
416 |
procdesc_free(pd); |
417 |
|
418 |
/* |
419 |
* Next, reparent it to init(8) so that there's |
420 |
* someone to pick up the pieces; finally, |
421 |
* terminate with prejudice. |
422 |
*/ |
423 |
p->p_sigparent = SIGCHLD; |
424 |
if (!(p->p_flag & P_TRACED)) { |
425 |
proc_reparent(p, initproc); |
426 |
} |
427 |
if ((pd->pd_flags & PDF_DAEMON) == 0) |
428 |
kern_psignal(p, SIGKILL); |
429 |
} |
412 |
|
430 |
|
413 |
/* |
|
|
414 |
* Next, reparent it to init(8) so that there's someone |
415 |
* to pick up the pieces; finally, terminate with |
416 |
* prejudice. |
417 |
*/ |
418 |
p->p_sigparent = SIGCHLD; |
419 |
proc_reparent(p, initproc); |
420 |
if ((pd->pd_flags & PDF_DAEMON) == 0) |
421 |
kern_psignal(p, SIGKILL); |
422 |
PROC_UNLOCK(p); |
431 |
PROC_UNLOCK(p); |
423 |
sx_xunlock(&proctree_lock); |
432 |
sx_xunlock(&proctree_lock); |
424 |
} |
433 |
} |