merge of bill's code plus lint (plus, of course, cleanup of bill's bugs)
[unix-history] / usr / src / sys / kern / kern_proc.c
CommitLineData
88a7a62a 1/* kern_proc.c 4.64 83/05/27 */
961945a8
SL
2
3#include "../machine/reg.h"
4#include "../machine/pte.h"
5#include "../machine/psl.h"
29dd101b
BJ
6
7#include "../h/param.h"
8#include "../h/systm.h"
9#include "../h/map.h"
29dd101b
BJ
10#include "../h/dir.h"
11#include "../h/user.h"
a1bce776 12#include "../h/kernel.h"
29dd101b
BJ
13#include "../h/proc.h"
14#include "../h/buf.h"
29dd101b
BJ
15#include "../h/inode.h"
16#include "../h/seg.h"
17#include "../h/acct.h"
cf1233e6 18#include "../h/wait.h"
29dd101b
BJ
19#include "../h/vm.h"
20#include "../h/text.h"
3ca1542b 21#include "../h/file.h"
feab6b5e 22#include "../h/quota.h"
6fd40cea 23#include "../h/uio.h"
a1bce776 24#include "../h/mbuf.h"
4f083fd7 25#include "../h/nami.h"
a1bce776 26
4147b3f6 27spgrp(top, npgrp)
88a7a62a 28 register struct proc *top;
4147b3f6
BJ
29{
30 register struct proc *pp, *p;
31 int f = 0;
32
33 for (p = top; npgrp == -1 || u.u_uid == p->p_uid ||
34 !u.u_uid || inferior(p); p = pp) {
35 if (npgrp == -1) {
36#define bit(a) (1<<(a-1))
37 p->p_sig &= ~(bit(SIGTSTP)|bit(SIGTTIN)|bit(SIGTTOU));
38 } else
39 p->p_pgrp = npgrp;
40 f++;
41 /*
42 * Search for children.
43 */
44 for (pp = proc; pp < procNPROC; pp++)
45 if (pp->p_pptr == p)
46 goto cont;
47 /*
48 * Search for siblings.
49 */
50 for (; p != top; p = p->p_pptr)
51 for (pp = p + 1; pp < procNPROC; pp++)
52 if (pp->p_pptr == p->p_pptr)
53 goto cont;
54 break;
55 cont:
56 ;
57 }
58 return (f);
59}
60
29dd101b 61/*
4147b3f6 62 * Is p an inferior of the current process?
29dd101b 63 */
4147b3f6 64inferior(p)
a2a2a0d6 65 register struct proc *p;
29dd101b 66{
29dd101b 67
4147b3f6
BJ
68 for (; p != u.u_procp; p = p->p_pptr)
69 if (p->p_ppid == 0)
70 return (0);
71 return (1);
29dd101b 72}
a2a2a0d6
BJ
73
74struct proc *
75pfind(pid)
76 int pid;
77{
78 register struct proc *p;
79
80 for (p = &proc[pidhash[PIDHASH(pid)]]; p != &proc[0]; p = &proc[p->p_idhash])
81 if (p->p_pid == pid)
82 return (p);
83 return ((struct proc *)0);
84}