Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177303016
D57124.1794113319.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D57124.1794113319.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 8, 4:48 AM (10 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41568232
Default Alt Text
D57124.1794113319.diff (1 KB)
Attached To
Mode
D57124: sys: add pdopenpid(2)
Attached
Detach File
Event Timeline