xref: /minix3/minix/servers/pm/mproc.h (revision 1122b2869164f2eba1e38403fef5d1a2ef5e2cfa)
1433d6423SLionel Sambuc /* This table has one slot per process.  It contains all the process management
2433d6423SLionel Sambuc  * information for each process.  Among other things, it defines the text, data
3433d6423SLionel Sambuc  * and stack segments, uids and gids, and various flags.  The kernel and file
4433d6423SLionel Sambuc  * systems have tables that are also indexed by process, with the contents
5433d6423SLionel Sambuc  * of corresponding slots referring to the same process in all three.
6433d6423SLionel Sambuc  */
7433d6423SLionel Sambuc #include <limits.h>
8433d6423SLionel Sambuc #include <minix/timers.h>
9433d6423SLionel Sambuc #include <signal.h>
10433d6423SLionel Sambuc 
11433d6423SLionel Sambuc #include <sys/cdefs.h>
12433d6423SLionel Sambuc 
13433d6423SLionel Sambuc /* Needs to be included here, for 'ps' etc */
14433d6423SLionel Sambuc #include "const.h"
15433d6423SLionel Sambuc 
166ad322a9SDavid van Moolenbroek /*
176ad322a9SDavid van Moolenbroek  * The per-process sigaction structures are stored outside of the mproc table,
186ad322a9SDavid van Moolenbroek  * so that the MIB service can avoid pulling them in, as they account for
196ad322a9SDavid van Moolenbroek  * roughly 80% of the per-process state.
206ad322a9SDavid van Moolenbroek  */
21129adfebSDavid van Moolenbroek typedef struct sigaction ixfer_sigaction;
226ad322a9SDavid van Moolenbroek EXTERN ixfer_sigaction mpsigact[NR_PROCS][_NSIG];
23129adfebSDavid van Moolenbroek 
24433d6423SLionel Sambuc EXTERN struct mproc {
25433d6423SLionel Sambuc   char mp_exitstatus;		/* storage for status when process exits */
26433d6423SLionel Sambuc   char mp_sigstatus;		/* storage for signal # for killed procs */
27910831cbSDavid van Moolenbroek   char mp_eventsub;		/* process event subscriber, or NO_EVENTSUB */
28433d6423SLionel Sambuc   pid_t mp_pid;			/* process id */
29433d6423SLionel Sambuc   endpoint_t mp_endpoint;	/* kernel endpoint id */
30433d6423SLionel Sambuc   pid_t mp_procgrp;		/* pid of process group (used for signals) */
31433d6423SLionel Sambuc   pid_t mp_wpid;		/* pid this process is waiting for */
3229346ab0SDavid van Moolenbroek   vir_bytes mp_waddr;		/* struct rusage address while waiting */
33433d6423SLionel Sambuc   int mp_parent;		/* index of parent process */
34433d6423SLionel Sambuc   int mp_tracer;		/* index of tracer process, or NO_TRACER */
35433d6423SLionel Sambuc 
36433d6423SLionel Sambuc   /* Child user and system times. Accounting done on child exit. */
37433d6423SLionel Sambuc   clock_t mp_child_utime;	/* cumulative user time of children */
38433d6423SLionel Sambuc   clock_t mp_child_stime;	/* cumulative sys time of children */
39433d6423SLionel Sambuc 
40*1122b286SDavid van Moolenbroek   /* Real, effective, and saved user and group IDs. */
41433d6423SLionel Sambuc   uid_t mp_realuid;		/* process' real uid */
42433d6423SLionel Sambuc   uid_t mp_effuid;		/* process' effective uid */
43*1122b286SDavid van Moolenbroek   uid_t mp_svuid;		/* process' saved uid */
44433d6423SLionel Sambuc   gid_t mp_realgid;		/* process' real gid */
45433d6423SLionel Sambuc   gid_t mp_effgid;		/* process' effective gid */
46*1122b286SDavid van Moolenbroek   gid_t mp_svgid;		/* process' saved gid */
47433d6423SLionel Sambuc 
48433d6423SLionel Sambuc   /* Supplemental groups. */
49433d6423SLionel Sambuc   int mp_ngroups;		/* number of supplemental groups */
50433d6423SLionel Sambuc   gid_t mp_sgroups[NGROUPS_MAX];/* process' supplemental groups */
51433d6423SLionel Sambuc 
52433d6423SLionel Sambuc   /* Signal handling information. */
53433d6423SLionel Sambuc   sigset_t mp_ignore;		/* 1 means ignore the signal, 0 means don't */
54433d6423SLionel Sambuc   sigset_t mp_catch;		/* 1 means catch the signal, 0 means don't */
55433d6423SLionel Sambuc   sigset_t mp_sigmask;		/* signals to be blocked */
56433d6423SLionel Sambuc   sigset_t mp_sigmask2;		/* saved copy of mp_sigmask */
57433d6423SLionel Sambuc   sigset_t mp_sigpending;	/* pending signals to be handled */
58433d6423SLionel Sambuc   sigset_t mp_ksigpending;	/* bitmap for pending signals from the kernel */
59433d6423SLionel Sambuc   sigset_t mp_sigtrace;		/* signals to hand to tracer first */
606ad322a9SDavid van Moolenbroek   ixfer_sigaction *mp_sigact;	/* as in sigaction(2), pointer into mpsigact */
61433d6423SLionel Sambuc   vir_bytes mp_sigreturn; 	/* address of C library __sigreturn function */
62433d6423SLionel Sambuc   minix_timer_t mp_timer;	/* watchdog timer for alarm(2), setitimer(2) */
63433d6423SLionel Sambuc   clock_t mp_interval[NR_ITIMERS];	/* setitimer(2) repetition intervals */
6458be976dSDavid van Moolenbroek   clock_t mp_started;		/* when the process was started, for ps(1) */
65433d6423SLionel Sambuc 
66433d6423SLionel Sambuc   unsigned mp_flags;		/* flag bits */
67433d6423SLionel Sambuc   unsigned mp_trace_flags;	/* trace options */
68433d6423SLionel Sambuc   message mp_reply;		/* reply message to be sent to one */
69433d6423SLionel Sambuc 
70433d6423SLionel Sambuc   /* Process execution frame. Both fields are used by procfs. */
71433d6423SLionel Sambuc   vir_bytes mp_frame_addr;	/* ptr to proc's initial stack arguments */
72433d6423SLionel Sambuc   size_t mp_frame_len;		/* size of proc's initial stack arguments */
73433d6423SLionel Sambuc 
74433d6423SLionel Sambuc   /* Scheduling priority. */
75433d6423SLionel Sambuc   signed int mp_nice;		/* nice is PRIO_MIN..PRIO_MAX, standard 0. */
76433d6423SLionel Sambuc 
77433d6423SLionel Sambuc   /* User space scheduling */
78433d6423SLionel Sambuc   endpoint_t mp_scheduler;	/* scheduler endpoint id */
79433d6423SLionel Sambuc 
80433d6423SLionel Sambuc   char mp_name[PROC_NAME_LEN];	/* process name */
81433d6423SLionel Sambuc 
82433d6423SLionel Sambuc   int mp_magic;			/* sanity check, MP_MAGIC */
83433d6423SLionel Sambuc } mproc[NR_PROCS];
84433d6423SLionel Sambuc 
85433d6423SLionel Sambuc /* Flag values */
86433d6423SLionel Sambuc #define IN_USE		0x00001	/* set when 'mproc' slot in use */
8729346ab0SDavid van Moolenbroek #define WAITING		0x00002	/* set by WAIT4 system call */
8829346ab0SDavid van Moolenbroek #define ZOMBIE		0x00004	/* waiting for parent to issue WAIT4 call */
89433d6423SLionel Sambuc #define PROC_STOPPED	0x00008	/* process is stopped in the kernel */
90433d6423SLionel Sambuc #define ALARM_ON	0x00010	/* set when SIGALRM timer started */
91433d6423SLionel Sambuc #define EXITING		0x00020	/* set by EXIT, process is now exiting */
92433d6423SLionel Sambuc #define TOLD_PARENT	0x00040	/* parent wait() completed, ZOMBIE off */
93433d6423SLionel Sambuc #define TRACE_STOPPED	0x00080	/* set if process stopped for tracing */
94433d6423SLionel Sambuc #define SIGSUSPENDED	0x00100	/* set by SIGSUSPEND system call */
95433d6423SLionel Sambuc #define VFS_CALL       	0x00400	/* set if waiting for VFS (normal calls) */
96433d6423SLionel Sambuc #define NEW_PARENT	0x00800	/* process's parent changed during VFS call */
97433d6423SLionel Sambuc #define UNPAUSED	0x01000	/* VFS has replied to unpause request */
98433d6423SLionel Sambuc #define PRIV_PROC	0x02000	/* system process, special privileges */
99433d6423SLionel Sambuc #define PARTIAL_EXEC	0x04000	/* process got a new map but no content */
100433d6423SLionel Sambuc #define TRACE_EXIT	0x08000	/* tracer is forcing this process to exit */
10129346ab0SDavid van Moolenbroek #define TRACE_ZOMBIE	0x10000	/* waiting for tracer to issue WAIT4 call */
102433d6423SLionel Sambuc #define DELAY_CALL	0x20000	/* waiting for call before sending signal */
103433d6423SLionel Sambuc #define TAINTED		0x40000 /* process is 'tainted' */
104910831cbSDavid van Moolenbroek #define EVENT_CALL	0x80000	/* waiting for process event subscriber */
105433d6423SLionel Sambuc 
106433d6423SLionel Sambuc #define MP_MAGIC	0xC0FFEE0
107