FreeBSD/sys/kern/kern_ktrace.c
/*
 * When a process exits, drain per-process asynchronous trace records
 * and disable tracing.
 */
When a process exits, drain per-process asynchronous trace records
and disable tracing.
When a process exits drain per - process asynchronous trace records and disable tracing .
void
ktrprocexit(struct thread *td)
{
	struct ktr_request *req;
	struct proc *p;
	struct ucred *cred;
	struct vnode *vp;
	p = td->td_proc;
	if (p->p_traceflag == 0)
		return;
	ktrace_enter(td);
	req = ktr_getrequest_entered(td, KTR_PROCDTOR);
	if (req != NULL)
		ktr_enqueuerequest(td, req);
	sx_xlock(&ktrace_sx);
	ktr_drain(td);
	sx_xunlock(&ktrace_sx);
	PROC_LOCK(p);
	mtx_lock(&ktrace_mtx);
	ktr_freeproc(p, &cred, &vp);
	mtx_unlock(&ktrace_mtx);
	PROC_UNLOCK(p);
	if (vp != NULL)
		vrele(vp);
	if (cred != NULL)
		crfree(cred);
	ktrace_exit(td);
}
void ktrprocexit ( struct thread * td ) { struct ktr_request * req ; struct proc * p ; struct ucred * cred ; struct vnode * vp ; p = td -> td_proc ; if ( p -> p_traceflag == 0 ) return ; ktrace_enter ( td ) ; req = ktr_getrequest_entered ( td , KTR_PROCDTOR ) ; if ( req != NULL ) ktr_enqueuerequest ( td , req ) ; sx_xlock ( & ktrace_sx ) ; ktr_drain ( td ) ; sx_xunlock ( & ktrace_sx ) ; PROC_LOCK ( p ) ; mtx_lock ( & ktrace_mtx ) ; ktr_freeproc ( p , & cred , & vp ) ; mtx_unlock ( & ktrace_mtx ) ; PROC_UNLOCK ( p ) ; if ( vp != NULL ) vrele ( vp ) ; if ( cred != NULL ) crfree ( cred ) ; ktrace_exit ( td ) ; }
When a process exits, drain per-process asynchronous trace records
 and disable tracing.
When a process exits drain per - process asynchronous trace records and disable tracing .