Page MenuHomeFreeBSD

D57124.id.diff
No OneTemporary

D57124.id.diff

diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c
--- a/sys/kern/sys_procdesc.c
+++ b/sys/kern/sys_procdesc.c
@@ -201,23 +201,15 @@
return (error);
}
-/*
- * When a new process is forked by pdfork(), a file descriptor is allocated
- * by the fork code first, then the process is forked, and then we get a
- * chance to set up the process descriptor. Failure is not permitted at this
- * point, so procdesc_new() must succeed.
- */
-void
-procdesc_new(struct proc *p, int flags)
+static struct procdesc *
+procdesc_alloc(int flags)
{
struct procdesc *pd;
pd = malloc(sizeof(*pd), M_PROCDESC, M_WAITOK | M_ZERO);
- pd->pd_proc = p;
- pd->pd_pid = p->p_pid;
- p->p_procdesc = pd;
pd->pd_flags = 0;
- if (flags & PD_DAEMON)
+ pd->pd_pid = -1;
+ if ((flags & PD_DAEMON) != 0)
pd->pd_flags |= PDF_DAEMON;
PROCDESC_LOCK_INIT(pd);
knlist_init_mtx(&pd->pd_selinfo.si_note, &pd->pd_lock);
@@ -227,6 +219,26 @@
* struct file, and the other from their struct proc.
*/
refcount_init(&pd->pd_refcount, 2);
+
+ return (pd);
+}
+
+/*
+ * When a new process is forked by pdfork(), a file descriptor is allocated
+ * by the fork code first, then the process is forked, and then we get a
+ * chance to set up the process descriptor. Failure is not permitted at this
+ * point, so procdesc_new() must succeed.
+ */
+void
+procdesc_new(struct proc *p, int flags)
+{
+ struct procdesc *pd;
+
+ pd = procdesc_alloc(flags);
+ pd->pd_proc = p;
+ pd->pd_pid = p->p_pid;
+ MPASS(p->p_procdesc == NULL);
+ p->p_procdesc = pd;
}
/*

File Metadata

Mime Type
text/plain
Expires
Fri, Jul 17, 1:53 AM (17 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34822548
Default Alt Text
D57124.id.diff (1 KB)

Event Timeline