/* kern_proc.c 6.4 84/08/29 */ #include "../machine/reg.h" #include "../machine/pte.h" #include "../machine/psl.h" #include "param.h" #include "systm.h" #include "map.h" #include "dir.h" #include "user.h" #include "kernel.h" #include "proc.h" #include "buf.h" #include "inode.h" #include "seg.h" #include "acct.h" #include "wait.h" #include "vm.h" #include "text.h" #include "file.h" #include "quota.h" #include "uio.h" #include "mbuf.h" spgrp(top, npgrp) register struct proc *top; { register struct proc *pp, *p; int f = 0; for (p = top; npgrp == -1 || u.u_uid == p->p_uid || !u.u_uid || inferior(p); p = pp) { if (npgrp == -1) { #define bit(a) (1<<(a-1)) p->p_sig &= ~(bit(SIGTSTP)|bit(SIGTTIN)|bit(SIGTTOU)); } else p->p_pgrp = npgrp; f++; /* * Search for children. */ for (pp = proc; pp < procNPROC; pp++) if (pp->p_pptr == p) goto cont; /* * Search for siblings. */ for (; p != top; p = p->p_pptr) for (pp = p + 1; pp < procNPROC; pp++) if (pp->p_pptr == p->p_pptr) goto cont; break; cont: ; } return (f); } /* * Is p an inferior of the current process? */ inferior(p) register struct proc *p; { for (; p != u.u_procp; p = p->p_pptr) if (p->p_ppid == 0) return (0); return (1); } struct proc * pfind(pid) int pid; { register struct proc *p; for (p = &proc[pidhash[PIDHASH(pid)]]; p != &proc[0]; p = &proc[p->p_idhash]) if (p->p_pid == pid) return (p); return ((struct proc *)0); } /* * init the process queues */ pqinit() { register struct proc *p; /* * most procs are initially on freequeue * nb: we place them there in their "natural" order. */ freeproc = NULL; for (p = procNPROC; --p > proc; freeproc = p) p->p_nxt = freeproc; /* * but proc[0] is special ... */ allproc = p; p->p_nxt = NULL; p->p_prev = &allproc; zombproc = NULL; }