The falloc() function obtains two references to newly created 'fp'.
On success we have to drop one after procdesc_finit() and on failure we have to close allocated slot with fdclose(), which also drops one reference for us and drop the remaining reference with fdrop(). Without this change closing process descriptor didn't result in killing pdfork(2)ed child. Reviewed by: rwatson MFC after: 1 month
This commit is contained in:
parent
cd4ecf3cd2
commit
0a7007b98f
@ -921,8 +921,10 @@ fork1(struct thread *td, int flags, int pages, struct proc **procp,
|
||||
*/
|
||||
*procp = newproc;
|
||||
#ifdef PROCDESC
|
||||
if (flags & RFPROCDESC)
|
||||
if (flags & RFPROCDESC) {
|
||||
procdesc_finit(newproc->p_procdesc, fp_procdesc);
|
||||
fdrop(fp_procdesc, td);
|
||||
}
|
||||
#endif
|
||||
racct_proc_fork_done(newproc);
|
||||
return (0);
|
||||
@ -944,8 +946,10 @@ fork1(struct thread *td, int flags, int pages, struct proc **procp,
|
||||
vmspace_free(vm2);
|
||||
uma_zfree(proc_zone, newproc);
|
||||
#ifdef PROCDESC
|
||||
if (((flags & RFPROCDESC) != 0) && (fp_procdesc != NULL))
|
||||
if (((flags & RFPROCDESC) != 0) && (fp_procdesc != NULL)) {
|
||||
fdclose(td->td_proc->p_fd, fp_procdesc, *procdescp, td);
|
||||
fdrop(fp_procdesc, td);
|
||||
}
|
||||
#endif
|
||||
pause("fork", hz / 2);
|
||||
return (error);
|
||||
|
Loading…
Reference in New Issue
Block a user