This source file includes following definitions.
- LIST_HEAD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 #ifndef _SYS_PROC_H_
41 #define _SYS_PROC_H_
42
43 #include <machine/proc.h>
44 #include <sys/selinfo.h>
45 #include <sys/queue.h>
46 #include <sys/timeout.h>
47 #include <sys/event.h>
48 #include <machine/atomic.h>
49
50 #define curproc curcpu()->ci_curproc
51 #ifdef _KERNEL
52 #define __need_process
53 #endif
54
55
56
57
58 struct session {
59 int s_count;
60 struct proc *s_leader;
61 struct vnode *s_ttyvp;
62 struct tty *s_ttyp;
63 char s_login[MAXLOGNAME];
64 };
65
66
67
68
69 struct pgrp {
70 LIST_ENTRY(pgrp) pg_hash;
71 LIST_HEAD(, proc) pg_members;
72 struct session *pg_session;
73 pid_t pg_id;
74 int pg_jobc;
75 };
76
77
78
79
80 struct exec_package;
81 struct ps_strings;
82 struct uvm_object;
83 union sigval;
84
85 struct emul {
86 char e_name[8];
87 int *e_errno;
88
89 void (*e_sendsig)(sig_t, int, int, u_long, int, union sigval);
90 int e_nosys;
91 int e_nsysent;
92 struct sysent *e_sysent;
93 char **e_syscallnames;
94 int e_arglen;
95
96 void *(*e_copyargs)(struct exec_package *, struct ps_strings *,
97 void *, void *);
98
99 void (*e_setregs)(struct proc *, struct exec_package *,
100 u_long, register_t *);
101 int (*e_fixup)(struct proc *, struct exec_package *);
102 char *e_sigcode;
103 char *e_esigcode;
104 int e_flags;
105 struct uvm_object *e_sigobject;
106
107 void (*e_proc_exec)(struct proc *, struct exec_package *);
108 void (*e_proc_fork)(struct proc *p, struct proc *parent);
109 void (*e_proc_exit)(struct proc *);
110 };
111
112 #define EMUL_ENABLED 0x0001
113 #define EMUL_NATIVE 0x0002
114
115 extern struct emul *emulsw[];
116 extern int nemuls;
117
118
119
120
121
122
123
124
125
126
127
128
129
130 #ifdef __need_process
131 struct process {
132
133
134
135
136
137
138
139
140 struct proc *ps_mainproc;
141 struct pcred *ps_cred;
142 struct plimit *ps_limit;
143
144 TAILQ_HEAD(,proc) ps_threads;
145 };
146 #else
147 struct process;
148 #endif
149
150 struct proc {
151 struct proc *p_forw;
152 struct proc *p_back;
153 LIST_ENTRY(proc) p_list;
154
155 struct process *p_p;
156 TAILQ_ENTRY(proc) p_thr_link;
157
158
159 struct filedesc *p_fd;
160 struct pstats *p_stats;
161 struct vmspace *p_vmspace;
162 struct sigacts *p_sigacts;
163 #define p_cred p_p->ps_cred
164 #define p_ucred p_cred->pc_ucred
165 #define p_rlimit p_p->ps_limit->pl_rlimit
166
167 int p_exitsig;
168 int p_flag;
169 u_char p_os;
170 char p_stat;
171 char p_pad1[1];
172 u_char p_descfd;
173
174 pid_t p_pid;
175 LIST_ENTRY(proc) p_hash;
176 LIST_ENTRY(proc) p_pglist;
177 struct proc *p_pptr;
178 LIST_ENTRY(proc) p_sibling;
179 LIST_HEAD(, proc) p_children;
180
181
182 #define p_startzero p_oppid
183
184 pid_t p_oppid;
185 int p_dupfd;
186
187 long p_thrslpid;
188
189
190
191 u_int p_estcpu;
192 int p_cpticks;
193 fixpt_t p_pctcpu;
194 void *p_wchan;
195 struct timeout p_sleep_to;
196 const char *p_wmesg;
197 u_int p_swtime;
198 u_int p_slptime;
199 struct cpu_info * __volatile p_cpu;
200
201 struct itimerval p_realtimer;
202 struct timeout p_realit_to;
203 struct timeval p_rtime;
204 u_quad_t p_uticks;
205 u_quad_t p_sticks;
206 u_quad_t p_iticks;
207
208 int p_traceflag;
209 struct vnode *p_tracep;
210
211 void *p_systrace;
212
213 int p_ptmask;
214 struct ptrace_state *p_ptstat;
215
216 int p_siglist;
217
218 struct vnode *p_textvp;
219
220 struct emul *p_emul;
221 void *p_emuldata;
222
223 struct klist p_klist;
224
225
226 sigset_t p_sigdivert;
227
228
229 #define p_endzero p_startcopy
230
231
232 #define p_startcopy p_sigmask
233
234 sigset_t p_sigmask;
235 sigset_t p_sigignore;
236 sigset_t p_sigcatch;
237
238 u_char p_priority;
239 u_char p_usrpri;
240 char p_nice;
241 char p_comm[MAXCOMLEN+1];
242
243 struct pgrp *p_pgrp;
244 vaddr_t p_sigcode;
245
246
247 #define p_endcopy p_addr
248
249 struct user *p_addr;
250 struct mdproc p_md;
251
252 u_short p_xstat;
253 u_short p_acflag;
254 struct rusage *p_ru;
255 };
256
257 #define p_session p_pgrp->pg_session
258 #define p_pgid p_pgrp->pg_id
259
260
261 #define SIDL 1
262 #define SRUN 2
263 #define SSLEEP 3
264 #define SSTOP 4
265 #define SZOMB 5
266 #define SDEAD 6
267 #define SONPROC 7
268
269 #define P_ZOMBIE(p) ((p)->p_stat == SZOMB || (p)->p_stat == SDEAD)
270
271
272 #define P_ADVLOCK 0x000001
273 #define P_CONTROLT 0x000002
274 #define P_INMEM 0x000004
275 #define P_NOCLDSTOP 0x000008
276 #define P_PPWAIT 0x000010
277 #define P_PROFIL 0x000020
278 #define P_SELECT 0x000040
279 #define P_SINTR 0x000080
280 #define P_SUGID 0x000100
281 #define P_SYSTEM 0x000200
282 #define P_TIMEOUT 0x000400
283 #define P_TRACED 0x000800
284 #define P_WAITED 0x001000
285
286 #define P_WEXIT 0x002000
287 #define P_EXEC 0x004000
288
289
290 #define P_OWEUPC 0x008000
291
292
293 #define P_SSTEP 0x020000
294 #define P_SUGIDEXEC 0x040000
295
296 #define P_NOCLDWAIT 0x080000
297 #define P_NOZOMBIE 0x100000
298 #define P_INEXEC 0x200000
299 #define P_SYSTRACE 0x400000
300 #define P_CONTINUED 0x800000
301 #define P_BIGLOCK 0x2000000
302 #define P_THREAD 0x4000000
303 #define P_IGNEXITRV 0x8000000
304 #define P_SOFTDEP 0x10000000
305 #define P_STOPPED 0x20000000
306
307 #define P_BITS \
308 ("\20\01ADVLOCK\02CTTY\04NOCLDSTOP\05PPWAIT\06PROFIL\07SELECT" \
309 "\010SINTR\011SUGID\012SYSTEM\013TIMEOUT\014TRACED\015WAITED\016WEXIT" \
310 "\017EXEC\020PWEUPC\022SSTEP\023SUGIDEXEC\024NOCLDWAIT" \
311 "\025NOZOMBIE\026INEXEC\027SYSTRACE\030CONTINUED\032BIGLOCK" \
312 "\033THREAD\034IGNEXITRV\035SOFTDEP\036STOPPED")
313
314
315 #define P_EXITSIG(p) \
316 (((p)->p_flag & P_TRACED) ? SIGCHLD : (p)->p_exitsig)
317
318
319
320
321
322
323
324
325 struct pcred {
326 struct ucred *pc_ucred;
327 uid_t p_ruid;
328 uid_t p_svuid;
329 gid_t p_rgid;
330 gid_t p_svgid;
331 int p_refcnt;
332 };
333
334 #ifdef _KERNEL
335
336 struct uidinfo {
337 LIST_ENTRY(uidinfo) ui_hash;
338 uid_t ui_uid;
339 long ui_proccnt;
340 long ui_lockcnt;
341 };
342
343 struct uidinfo *uid_find(uid_t);
344
345
346
347
348
349
350 #define PID_MAX 32766
351 #define NO_PID (PID_MAX+1)
352
353 #define SESS_LEADER(p) ((p)->p_session->s_leader == (p))
354 #define SESSHOLD(s) ((s)->s_count++)
355 #define SESSRELE(s) { \
356 if (--(s)->s_count == 0) \
357 pool_put(&session_pool, s); \
358 }
359
360
361
362
363 #define FORK_FORK 0x00000001
364 #define FORK_VFORK 0x00000002
365 #define FORK_RFORK 0x00000004
366 #define FORK_PPWAIT 0x00000008
367 #define FORK_SHAREFILES 0x00000010
368 #define FORK_CLEANFILES 0x00000020
369 #define FORK_NOZOMBIE 0x00000040
370 #define FORK_SHAREVM 0x00000080
371 #define FORK_SIGHAND 0x00000200
372 #define FORK_PTRACE 0x00000400
373 #define FORK_THREAD 0x00000800
374
375 #define EXIT_NORMAL 0x00000001
376 #define EXIT_THREAD 0x00000002
377
378 #define PIDHASH(pid) (&pidhashtbl[(pid) & pidhash])
379 extern LIST_HEAD(pidhashhead, proc) *pidhashtbl;
380 extern u_long pidhash;
381
382 #define PGRPHASH(pgid) (&pgrphashtbl[(pgid) & pgrphash])
383 extern LIST_HEAD(pgrphashhead, pgrp) *pgrphashtbl;
384 extern u_long pgrphash;
385
386 extern struct proc proc0;
387 extern int nprocs, maxproc;
388 extern int randompid;
389
390 LIST_HEAD(proclist, proc);
391 extern struct proclist allproc;
392 extern struct proclist zombproc;
393
394 extern struct proc *initproc;
395 extern struct proc *syncerproc;
396
397 extern struct pool process_pool;
398 extern struct pool proc_pool;
399 extern struct pool rusage_pool;
400 extern struct pool ucred_pool;
401 extern struct pool session_pool;
402 extern struct pool pcred_pool;
403
404 #define NQS 32
405 extern int whichqs;
406 struct prochd {
407 struct proc *ph_link;
408 struct proc *ph_rlink;
409 };
410 extern struct prochd qs[NQS];
411
412 struct simplelock;
413
414 struct proc *pfind(pid_t);
415 struct pgrp *pgfind(pid_t);
416 void proc_printit(struct proc *p, const char *modif,
417 int (*pr)(const char *, ...));
418
419 int chgproccnt(uid_t uid, int diff);
420 int enterpgrp(struct proc *p, pid_t pgid, int mksess);
421 void fixjobc(struct proc *p, struct pgrp *pgrp, int entering);
422 int inferior(struct proc *p);
423 int leavepgrp(struct proc *p);
424 void yield(void);
425 void preempt(struct proc *);
426 void mi_switch(void);
427 void pgdelete(struct pgrp *pgrp);
428 void procinit(void);
429 #if !defined(remrunqueue)
430 void remrunqueue(struct proc *);
431 #endif
432 void resetpriority(struct proc *);
433 void setrunnable(struct proc *);
434 #if !defined(setrunqueue)
435 void setrunqueue(struct proc *);
436 #endif
437 void unsleep(struct proc *);
438 void wakeup_n(void *chan, int);
439 void wakeup(void *chan);
440 #define wakeup_one(c) wakeup_n((c), 1)
441 void reaper(void);
442 void exit1(struct proc *, int, int);
443 void exit2(struct proc *);
444 int fork1(struct proc *, int, int, void *, size_t, void (*)(void *),
445 void *, register_t *, struct proc **);
446 void rqinit(void);
447 int groupmember(gid_t, struct ucred *);
448 #if !defined(cpu_switch)
449 void cpu_switch(struct proc *);
450 #endif
451 #if !defined(cpu_wait)
452 void cpu_wait(struct proc *);
453 #endif
454 void cpu_exit(struct proc *);
455
456 void child_return(void *);
457
458 int proc_cansugid(struct proc *);
459 void proc_zap(struct proc *);
460
461 struct sleep_state {
462 int sls_s;
463 int sls_catch;
464 int sls_do_sleep;
465 int sls_sig;
466 };
467
468 void sleep_setup(struct sleep_state *, void *, int, const char *);
469 void sleep_setup_timeout(struct sleep_state *, int);
470 void sleep_setup_signal(struct sleep_state *, int);
471 void sleep_finish(struct sleep_state *, int);
472 int sleep_finish_timeout(struct sleep_state *);
473 int sleep_finish_signal(struct sleep_state *);
474
475 int tsleep(void *, int, const char *, int);
476 #define ltsleep(c, p, w, t, l) tsleep(c, p, w, t)
477
478 #if defined(MULTIPROCESSOR)
479 void proc_trampoline_mp(void);
480 #endif
481
482 int proc_isunder(struct proc *, struct proc *);
483
484 #endif
485 #endif
486