Annotation of prex-old/usr/server/proc/proc.h, Revision 1.1.1.1
1.1 nbrk 1: /*
2: * Copyright (c) 2005-2007, Kohsuke Ohtani
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms, with or without
6: * modification, are permitted provided that the following conditions
7: * are met:
8: * 1. Redistributions of source code must retain the above copyright
9: * notice, this list of conditions and the following disclaimer.
10: * 2. Redistributions in binary form must reproduce the above copyright
11: * notice, this list of conditions and the following disclaimer in the
12: * documentation and/or other materials provided with the distribution.
13: * 3. Neither the name of the author nor the names of any co-contributors
14: * may be used to endorse or promote products derived from this software
15: * without specific prior written permission.
16: *
17: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20: * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27: * SUCH DAMAGE.
28: */
29:
30: #ifndef _PROC_H
31: #define _PROC_H
32:
33: #include <sys/param.h>
34: #include <sys/types.h>
35: #include <sys/list.h>
36: #include <sys/syslog.h>
37: #include <server/proc.h>
38: #include <server/stdmsg.h>
39:
40: #include <unistd.h>
41: #include <stdio.h>
42:
43: #ifdef DEBUG
44: /* #define DEBUG_PROC 1 */
45: #endif
46:
47: #ifdef DEBUG_PROC
48: #define dprintf(fmt, args...) syslog(LOG_DEBUG, "proc: " fmt, ## args)
49: #else
50: #define dprintf(fmt...) do {} while (0)
51: #endif
52:
53: #define PRIO_PROC 130 /* priority of process server */
54: #define PID_MAX 0x8000 /* max number for PID */
55:
56: #define ID_MAXBUCKETS 32
57: #define IDHASH(x) ((x) & (ID_MAXBUCKETS - 1))
58:
59: /*
60: * Process group
61: */
62: struct pgrp {
63: struct list pgid_link; /* link for pgid hash */
64: struct list members; /* list head of processes */
65: pid_t pgid; /* pgrp id */
66: };
67:
68: /*
69: * Description of a process.
70: */
71: struct proc {
72: struct list link; /* link for all processes */
73: struct proc *parent; /* pointer to parent process */
74: struct list children; /* list head of child processes */
75: struct list sibling; /* link for sibling processes */
76: struct list pid_link; /* link for pid hash */
77: struct list task_link; /* link for task hash */
78: struct list pgrp_link; /* link for process group */
79: struct pgrp *pgrp; /* pointer to process group */
80: int stat; /* process status S* */
81: int exit_code; /* exit code to send to parrent */
82: int wait_vfork; /* true while processing vfork() */
83: pid_t pid; /* process id */
84: task_t task; /* task id */
85: cap_t cap; /* capability of the task */
86: void *stack_base; /* pointer to stack */
87: void *stack_saved; /* pointer to saved stack */
88: };
89:
90: /*
91: * stat codes
92: */
93: #define SRUN 1 /* running */
94: #define SZOMB 2 /* process terminated but not waited for */
95: #define SSTOP 3 /* proces stopped */
96:
97: /*
98: * Global variables.
99: */
100: extern struct proc initproc; /* process slot for init */
101: extern struct list allproc; /* list of all processes */
102: extern struct proc *curproc; /* current (caller) process */
103:
104: extern pid_t pid_assign(void);
105: extern struct proc *proc_find(pid_t);
106: extern struct pgrp *pgrp_find(pid_t);
107: extern struct proc *task_to_proc(task_t);
108: extern void proc_add(struct proc *);
109: extern void proc_remove(struct proc *);
110: extern void pgrp_add(struct pgrp *);
111: extern void pgrp_remove(struct pgrp *);
112: extern void table_init(void);
113: extern void pid_init(void);
114: extern void proc_cleanup(struct proc *);
115: extern void vfork_end(struct proc *);
116: extern int kill_pg(pid_t, int);
117: extern void tty_init(void);
118:
119: extern int proc_getpid(struct msg *);
120: extern int proc_getppid(struct msg *);
121: extern int proc_getpgid(struct msg *);
122: extern int proc_setpgid(struct msg *);
123: extern int proc_fork(struct msg *);
124: extern int proc_exit(struct msg *);
125: extern int proc_stop(struct msg *);
126: extern int proc_waitpid(struct msg *);
127: extern int proc_kill(struct msg *);
128:
129: #endif /* !_PROC_H */
CVSweb