xref: /csrg-svn/sys/kern/kern_proc.c (revision 12749)
1*12749Ssam /*	kern_proc.c	4.64	83/05/27	*/
236Sbill 
39753Ssam #include "../machine/reg.h"
49753Ssam #include "../machine/pte.h"
59753Ssam #include "../machine/psl.h"
69753Ssam 
736Sbill #include "../h/param.h"
836Sbill #include "../h/systm.h"
936Sbill #include "../h/map.h"
1036Sbill #include "../h/dir.h"
1136Sbill #include "../h/user.h"
128030Sroot #include "../h/kernel.h"
1336Sbill #include "../h/proc.h"
1436Sbill #include "../h/buf.h"
1536Sbill #include "../h/inode.h"
1636Sbill #include "../h/seg.h"
1736Sbill #include "../h/acct.h"
1810887Ssam #include "../h/wait.h"
1936Sbill #include "../h/vm.h"
2036Sbill #include "../h/text.h"
21890Sbill #include "../h/file.h"
227488Skre #include "../h/quota.h"
237713Sroot #include "../h/uio.h"
248030Sroot #include "../h/mbuf.h"
259159Ssam #include "../h/nami.h"
2636Sbill 
277497Sroot spgrp(top, npgrp)
28*12749Ssam 	register struct proc *top;
297497Sroot {
307497Sroot 	register struct proc *pp, *p;
317497Sroot 	int f = 0;
327497Sroot 
337497Sroot 	for (p = top; npgrp == -1 || u.u_uid == p->p_uid ||
347497Sroot 	    !u.u_uid || inferior(p); p = pp) {
357497Sroot 		if (npgrp == -1) {
367497Sroot #define	bit(a)	(1<<(a-1))
377497Sroot 			p->p_sig &= ~(bit(SIGTSTP)|bit(SIGTTIN)|bit(SIGTTOU));
387497Sroot 		} else
397497Sroot 			p->p_pgrp = npgrp;
407497Sroot 		f++;
417497Sroot 		/*
427497Sroot 		 * Search for children.
437497Sroot 		 */
447497Sroot 		for (pp = proc; pp < procNPROC; pp++)
457497Sroot 			if (pp->p_pptr == p)
467497Sroot 				goto cont;
477497Sroot 		/*
487497Sroot 		 * Search for siblings.
497497Sroot 		 */
507497Sroot 		for (; p != top; p = p->p_pptr)
517497Sroot 			for (pp = p + 1; pp < procNPROC; pp++)
527497Sroot 				if (pp->p_pptr == p->p_pptr)
537497Sroot 					goto cont;
547497Sroot 		break;
557497Sroot 	cont:
567497Sroot 		;
577497Sroot 	}
587497Sroot 	return (f);
597497Sroot }
607497Sroot 
6136Sbill /*
627497Sroot  * Is p an inferior of the current process?
6336Sbill  */
647497Sroot inferior(p)
657816Sroot 	register struct proc *p;
6636Sbill {
6736Sbill 
687497Sroot 	for (; p != u.u_procp; p = p->p_pptr)
697497Sroot 		if (p->p_ppid == 0)
707497Sroot 			return (0);
717497Sroot 	return (1);
7236Sbill }
737816Sroot 
747816Sroot struct proc *
757816Sroot pfind(pid)
767816Sroot 	int pid;
777816Sroot {
787816Sroot 	register struct proc *p;
797816Sroot 
807816Sroot 	for (p = &proc[pidhash[PIDHASH(pid)]]; p != &proc[0]; p = &proc[p->p_idhash])
817816Sroot 		if (p->p_pid == pid)
827816Sroot 			return (p);
837816Sroot 	return ((struct proc *)0);
847816Sroot }
85