FreeBSD/sys/kern/kern_proc.c
/*
 * Adjust pgrp jobc counters when specified process changes process group.
 * We count the number of processes in each process group that "qualify"
 * the group for terminal job control (those with a parent in a different
 * process group of the same session).  If that count reaches zero, the
 * process group becomes orphaned.  Check both the specified process'
 * process group and that of its children.
 * entering == 0 => p is leaving specified group.
 * entering == 1 => p is entering specified group.
 */
Adjust pgrp jobc counters when specified process changes process group.
We count the number of processes in each process group that "qualify"
the group for terminal job control (those with a parent in a different
process group of the same session).  If that count reaches zero, the
process group becomes orphaned.  Check both the specified process'
process group and that of its children.
entering == 0 => p is leaving specified group.
entering == 1 => p is entering specified group.
Adjust pgrp jobc counters when specified process changes process group . We count the number of processes in each process group that " qualify " the group for terminal job control ( those with a parent in a different process group of the same session ) . If that count reaches zero the process group becomes orphaned . Check both the specified process ' process group and that of its children . entering == 0 = > p is leaving specified group . entering == 1 = > p is entering specified group .
void
fixjobc(struct proc *p, struct pgrp *pgrp, int entering)
{
	struct pgrp *hispgrp;
	struct session *mysession;
	struct proc *q;
	sx_assert(&proctree_lock, SX_LOCKED);
	PROC_LOCK_ASSERT(p, MA_NOTOWNED);
	PGRP_LOCK_ASSERT(pgrp, MA_NOTOWNED);
	SESS_LOCK_ASSERT(pgrp->pg_session, MA_NOTOWNED);
	mysession = pgrp->pg_session;
	if ((hispgrp = p->p_pptr->p_pgrp) != pgrp &&
	    hispgrp->pg_session == mysession)
		pgadjustjobc(pgrp, entering);
	LIST_FOREACH(q, &p->p_children, p_sibling) {
		hispgrp = q->p_pgrp;
		if (hispgrp == pgrp ||
		    hispgrp->pg_session != mysession)
			continue;
		if (q->p_state == PRS_ZOMBIE)
			continue;
		pgadjustjobc(hispgrp, entering);
	}
}
void fixjobc ( struct proc * p , struct pgrp * pgrp , int entering ) { struct pgrp * hispgrp ; struct session * mysession ; struct proc * q ; sx_assert ( & proctree_lock , SX_LOCKED ) ; PROC_LOCK_ASSERT ( p , MA_NOTOWNED ) ; PGRP_LOCK_ASSERT ( pgrp , MA_NOTOWNED ) ; SESS_LOCK_ASSERT ( pgrp -> pg_session , MA_NOTOWNED ) ; mysession = pgrp -> pg_session ; if ( ( hispgrp = p -> p_pptr -> p_pgrp ) != pgrp && hispgrp -> pg_session == mysession ) pgadjustjobc ( pgrp , entering ) ; LIST_FOREACH ( q , & p -> p_children , p_sibling ) { hispgrp = q -> p_pgrp ; if ( hispgrp == pgrp || hispgrp -> pg_session != mysession ) continue ; if ( q -> p_state == PRS_ZOMBIE ) continue ; pgadjustjobc ( hispgrp , entering ) ; } }
Adjust pgrp jobc counters when specified process changes process group.
Adjust pgrp jobc counters when specified process changes process group .
/*
	 * Check p's parent to see whether p qualifies its own process
	 * group; if so, adjust count for p's process group.
	 */ /*
	 * Check this process' children to see whether they qualify
	 * their process groups; if so, adjust counts for children's
	 * process groups.
	 */