Page MenuHomeFreeBSD

D29207.id85522.diff
No OneTemporary

D29207.id85522.diff

Index: sys/kern/kern_fork.c
===================================================================
--- sys/kern/kern_fork.c
+++ sys/kern/kern_fork.c
@@ -502,6 +502,8 @@
sig_drop_caught(p2);
mtx_unlock(&p2->p_sigacts->ps_mtx);
}
+ if ((fr->fr_flags2 & FR2_KPROC) != 0)
+ p2->p_sigacts->ps_flag |= PS_NOCLDWAIT;
}
if (fr->fr_flags & RFTSIGZMB)
@@ -511,6 +513,11 @@
else
p2->p_sigparent = SIGCHLD;
+ if ((fr->fr_flags2 & FR2_KPROC) != 0) {
+ p2->p_flag |= P_SYSTEM | P_KPROC;
+ td2->td_pflags |= TDP_KTHREAD;
+ }
+
p2->p_textvp = p1->p_textvp;
p2->p_fd = fd;
p2->p_fdtol = fdtol;
Index: sys/kern/kern_kthread.c
===================================================================
--- sys/kern/kern_kthread.c
+++ sys/kern/kern_kthread.c
@@ -95,6 +95,7 @@
bzero(&fr, sizeof(fr));
fr.fr_flags = RFMEM | RFFDG | RFPROC | RFSTOPPED | flags;
+ fr.fr_flags2 = FR2_KPROC;
fr.fr_pages = pages;
fr.fr_procp = &p2;
error = fork1(&thread0, &fr);
@@ -105,21 +106,11 @@
if (newpp != NULL)
*newpp = p2;
- /* this is a non-swapped system process */
- PROC_LOCK(p2);
- td = FIRST_THREAD_IN_PROC(p2);
- p2->p_flag |= P_SYSTEM | P_KPROC;
- td->td_pflags |= TDP_KTHREAD;
- mtx_lock(&p2->p_sigacts->ps_mtx);
- p2->p_sigacts->ps_flag |= PS_NOCLDWAIT;
- mtx_unlock(&p2->p_sigacts->ps_mtx);
- PROC_UNLOCK(p2);
-
/* set up arg0 for 'ps', et al */
va_start(ap, fmt);
vsnprintf(p2->p_comm, sizeof(p2->p_comm), fmt, ap);
va_end(ap);
- /* set up arg0 for 'ps', et al */
+ td = FIRST_THREAD_IN_PROC(p2);
va_start(ap, fmt);
vsnprintf(td->td_name, sizeof(td->td_name), fmt, ap);
va_end(ap);
@@ -295,12 +286,14 @@
TSTHREAD(newtd, newtd->td_name);
newtd->td_proc = p; /* needed for cpu_copy_thread */
+ newtd->td_pflags |= TDP_KTHREAD;
+
/* might be further optimized for kthread */
cpu_copy_thread(newtd, oldtd);
+
/* put the designated function(arg) as the resume context */
cpu_fork_kthread_handler(newtd, func, arg);
- newtd->td_pflags |= TDP_KTHREAD;
thread_cow_get_proc(newtd, p);
/* this code almost the same as create_thread() in kern_thr.c */
Index: sys/sys/proc.h
===================================================================
--- sys/sys/proc.h
+++ sys/sys/proc.h
@@ -1055,6 +1055,7 @@
int fr_flags2;
#define FR2_DROPSIG_CAUGHT 0x00000001 /* Drop caught non-DFL signals */
#define FR2_SHARE_PATHS 0x00000002 /* Invert sense of RFFDG for paths */
+#define FR2_KPROC 0x00000004 /* Create a kernel process */
};
/*

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 23, 6:19 PM (52 m, 55 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35410904
Default Alt Text
D29207.id85522.diff (2 KB)

Event Timeline