MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ktrprocfork

Function ktrprocfork

freebsd/kern/kern_ktrace.c:582–607  ·  view source on GitHub ↗

* When a process forks, enable tracing in the new process if needed. */

Source from the content-addressed store, hash-verified

580 * When a process forks, enable tracing in the new process if needed.
581 */
582void
583ktrprocfork(struct proc *p1, struct proc *p2)
584{
585
586 MPASS(p2->p_tracevp == NULL);
587 MPASS(p2->p_traceflag == 0);
588
589 if (p1->p_traceflag == 0)
590 return;
591
592 PROC_LOCK(p1);
593 mtx_lock(&ktrace_mtx);
594 if (p1->p_traceflag & KTRFAC_INHERIT) {
595 p2->p_traceflag = p1->p_traceflag;
596 if ((p2->p_tracevp = p1->p_tracevp) != NULL) {
597 VREF(p2->p_tracevp);
598 KASSERT(p1->p_tracecred != NULL,
599 ("ktrace vnode with no cred"));
600 p2->p_tracecred = crhold(p1->p_tracecred);
601 }
602 }
603 mtx_unlock(&ktrace_mtx);
604 PROC_UNLOCK(p1);
605
606 ktrprocctor(p2);
607}
608
609/*
610 * When a thread returns, drain any asynchronous records generated by the

Callers 1

do_forkFunction · 0.85

Calls 4

ktrprocctorFunction · 0.85
mtx_lockFunction · 0.70
crholdFunction · 0.70
mtx_unlockFunction · 0.70

Tested by

no test coverage detected