Fix mbuf handling for unsupported operations
[unix-history] / usr / src / sys / kern / kern_proc.c
CommitLineData
715baff1 1/* kern_proc.c 6.3 84/07/08 */
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
BJ
24#include "../h/mbuf.h"
25
4147b3f6 26spgrp(top, npgrp)
88a7a62a 27 register struct proc *top;
4147b3f6
BJ
28{
29 register struct proc *pp, *p;
30 int f = 0;
31
32 for (p = top; npgrp == -1 || u.u_uid == p->p_uid ||
33 !u.u_uid || inferior(p); p = pp) {
34 if (npgrp == -1) {
35#define bit(a) (1<<(a-1))
36 p->p_sig &= ~(bit(SIGTSTP)|bit(SIGTTIN)|bit(SIGTTOU));
37 } else
38 p->p_pgrp = npgrp;
39 f++;
40 /*
41 * Search for children.
42 */
43 for (pp = proc; pp < procNPROC; pp++)
44 if (pp->p_pptr == p)
45 goto cont;
46 /*
47 * Search for siblings.
48 */
49 for (; p != top; p = p->p_pptr)
50 for (pp = p + 1; pp < procNPROC; pp++)
51 if (pp->p_pptr == p->p_pptr)
52 goto cont;
53 break;
54 cont:
55 ;
56 }
57 return (f);
58}
59
29dd101b 60/*
4147b3f6 61 * Is p an inferior of the current process?
29dd101b 62 */
4147b3f6 63inferior(p)
a2a2a0d6 64 register struct proc *p;
29dd101b 65{
29dd101b 66
4147b3f6
BJ
67 for (; p != u.u_procp; p = p->p_pptr)
68 if (p->p_ppid == 0)
69 return (0);
70 return (1);
29dd101b 71}
a2a2a0d6
BJ
72
73struct proc *
74pfind(pid)
75 int pid;
76{
77 register struct proc *p;
78
79 for (p = &proc[pidhash[PIDHASH(pid)]]; p != &proc[0]; p = &proc[p->p_idhash])
80 if (p->p_pid == pid)
81 return (p);
82 return ((struct proc *)0);
83}
1d348849
MK
84
85/*
86 * init the process queues
87 */
88pqinit()
89{
90 register struct proc *p;
91
92 /*
93 * most procs are initially on freequeue
94 * nb: we place them there in their "natural" order.
95 */
96
97 freeproc = NULL;
98 for (p = procNPROC; --p > proc; freeproc = p)
99 p->p_nxt = freeproc;
100
101 /*
102 * but proc[0] is special ...
103 */
104
105 allproc = p;
106 p->p_nxt = NULL;
107 p->p_prev = &allproc;
108
109 zombproc = NULL;
110}