xref: /minix3/minix/servers/pm/mproc.h (revision 226d301a626d367005d9527f8125f11ac9f7983b)
1 /* This table has one slot per process.  It contains all the process management
2  * information for each process.  Among other things, it defines the text, data
3  * and stack segments, uids and gids, and various flags.  The kernel and file
4  * systems have tables that are also indexed by process, with the contents
5  * of corresponding slots referring to the same process in all three.
6  */
7 #include <limits.h>
8 #include <minix/timers.h>
9 #include <signal.h>
10 
11 #include <sys/cdefs.h>
12 
13 /* Needs to be included here, for 'ps' etc */
14 #include "const.h"
15 
16 /*
17  * The per-process sigaction structures are stored outside of the mproc table,
18  * so that the MIB service can avoid pulling them in, as they account for
19  * roughly 80% of the per-process state.
20  */
21 typedef struct sigaction ixfer_sigaction;
22 EXTERN ixfer_sigaction mpsigact[NR_PROCS][_NSIG];
23 
24 EXTERN struct mproc {
25   char mp_exitstatus;		/* storage for status when process exits */
26   char mp_sigstatus;		/* storage for signal # for killed procs */
27   char mp_eventsub;		/* process event subscriber, or NO_EVENTSUB */
28   pid_t mp_pid;			/* process id */
29   endpoint_t mp_endpoint;	/* kernel endpoint id */
30   pid_t mp_procgrp;		/* pid of process group (used for signals) */
31   pid_t mp_wpid;		/* pid this process is waiting for */
32   vir_bytes mp_waddr;		/* struct rusage address while waiting */
33   int mp_parent;		/* index of parent process */
34   int mp_tracer;		/* index of tracer process, or NO_TRACER */
35 
36   /* Child user and system times. Accounting done on child exit. */
37   clock_t mp_child_utime;	/* cumulative user time of children */
38   clock_t mp_child_stime;	/* cumulative sys time of children */
39 
40   /* Real and effective uids and gids. */
41   uid_t mp_realuid;		/* process' real uid */
42   uid_t mp_effuid;		/* process' effective uid */
43   gid_t mp_realgid;		/* process' real gid */
44   gid_t mp_effgid;		/* process' effective gid */
45 
46   /* Supplemental groups. */
47   int mp_ngroups;		/* number of supplemental groups */
48   gid_t mp_sgroups[NGROUPS_MAX];/* process' supplemental groups */
49 
50   /* Signal handling information. */
51   sigset_t mp_ignore;		/* 1 means ignore the signal, 0 means don't */
52   sigset_t mp_catch;		/* 1 means catch the signal, 0 means don't */
53   sigset_t mp_sigmask;		/* signals to be blocked */
54   sigset_t mp_sigmask2;		/* saved copy of mp_sigmask */
55   sigset_t mp_sigpending;	/* pending signals to be handled */
56   sigset_t mp_ksigpending;	/* bitmap for pending signals from the kernel */
57   sigset_t mp_sigtrace;		/* signals to hand to tracer first */
58   ixfer_sigaction *mp_sigact;	/* as in sigaction(2), pointer into mpsigact */
59   vir_bytes mp_sigreturn; 	/* address of C library __sigreturn function */
60   minix_timer_t mp_timer;	/* watchdog timer for alarm(2), setitimer(2) */
61   clock_t mp_interval[NR_ITIMERS];	/* setitimer(2) repetition intervals */
62   clock_t mp_started;		/* when the process was started, for ps(1) */
63 
64   unsigned mp_flags;		/* flag bits */
65   unsigned mp_trace_flags;	/* trace options */
66   message mp_reply;		/* reply message to be sent to one */
67 
68   /* Process execution frame. Both fields are used by procfs. */
69   vir_bytes mp_frame_addr;	/* ptr to proc's initial stack arguments */
70   size_t mp_frame_len;		/* size of proc's initial stack arguments */
71 
72   /* Scheduling priority. */
73   signed int mp_nice;		/* nice is PRIO_MIN..PRIO_MAX, standard 0. */
74 
75   /* User space scheduling */
76   endpoint_t mp_scheduler;	/* scheduler endpoint id */
77 
78   char mp_name[PROC_NAME_LEN];	/* process name */
79 
80   int mp_magic;			/* sanity check, MP_MAGIC */
81 } mproc[NR_PROCS];
82 
83 /* Flag values */
84 #define IN_USE		0x00001	/* set when 'mproc' slot in use */
85 #define WAITING		0x00002	/* set by WAIT4 system call */
86 #define ZOMBIE		0x00004	/* waiting for parent to issue WAIT4 call */
87 #define PROC_STOPPED	0x00008	/* process is stopped in the kernel */
88 #define ALARM_ON	0x00010	/* set when SIGALRM timer started */
89 #define EXITING		0x00020	/* set by EXIT, process is now exiting */
90 #define TOLD_PARENT	0x00040	/* parent wait() completed, ZOMBIE off */
91 #define TRACE_STOPPED	0x00080	/* set if process stopped for tracing */
92 #define SIGSUSPENDED	0x00100	/* set by SIGSUSPEND system call */
93 #define VFS_CALL       	0x00400	/* set if waiting for VFS (normal calls) */
94 #define NEW_PARENT	0x00800	/* process's parent changed during VFS call */
95 #define UNPAUSED	0x01000	/* VFS has replied to unpause request */
96 #define PRIV_PROC	0x02000	/* system process, special privileges */
97 #define PARTIAL_EXEC	0x04000	/* process got a new map but no content */
98 #define TRACE_EXIT	0x08000	/* tracer is forcing this process to exit */
99 #define TRACE_ZOMBIE	0x10000	/* waiting for tracer to issue WAIT4 call */
100 #define DELAY_CALL	0x20000	/* waiting for call before sending signal */
101 #define TAINTED		0x40000 /* process is 'tainted' */
102 #define EVENT_CALL	0x80000	/* waiting for process event subscriber */
103 
104 #define MP_MAGIC	0xC0FFEE0
105