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, effective, and saved user and group IDs. */ 41 uid_t mp_realuid; /* process' real uid */ 42 uid_t mp_effuid; /* process' effective uid */ 43 uid_t mp_svuid; /* process' saved uid */ 44 gid_t mp_realgid; /* process' real gid */ 45 gid_t mp_effgid; /* process' effective gid */ 46 gid_t mp_svgid; /* process' saved gid */ 47 48 /* Supplemental groups. */ 49 int mp_ngroups; /* number of supplemental groups */ 50 gid_t mp_sgroups[NGROUPS_MAX];/* process' supplemental groups */ 51 52 /* Signal handling information. */ 53 sigset_t mp_ignore; /* 1 means ignore the signal, 0 means don't */ 54 sigset_t mp_catch; /* 1 means catch the signal, 0 means don't */ 55 sigset_t mp_sigmask; /* signals to be blocked */ 56 sigset_t mp_sigmask2; /* saved copy of mp_sigmask */ 57 sigset_t mp_sigpending; /* pending signals to be handled */ 58 sigset_t mp_ksigpending; /* bitmap for pending signals from the kernel */ 59 sigset_t mp_sigtrace; /* signals to hand to tracer first */ 60 ixfer_sigaction *mp_sigact; /* as in sigaction(2), pointer into mpsigact */ 61 vir_bytes mp_sigreturn; /* address of C library __sigreturn function */ 62 minix_timer_t mp_timer; /* watchdog timer for alarm(2), setitimer(2) */ 63 clock_t mp_interval[NR_ITIMERS]; /* setitimer(2) repetition intervals */ 64 clock_t mp_started; /* when the process was started, for ps(1) */ 65 66 unsigned mp_flags; /* flag bits */ 67 unsigned mp_trace_flags; /* trace options */ 68 message mp_reply; /* reply message to be sent to one */ 69 70 /* Process execution frame. Both fields are used by procfs. */ 71 vir_bytes mp_frame_addr; /* ptr to proc's initial stack arguments */ 72 size_t mp_frame_len; /* size of proc's initial stack arguments */ 73 74 /* Scheduling priority. */ 75 signed int mp_nice; /* nice is PRIO_MIN..PRIO_MAX, standard 0. */ 76 77 /* User space scheduling */ 78 endpoint_t mp_scheduler; /* scheduler endpoint id */ 79 80 char mp_name[PROC_NAME_LEN]; /* process name */ 81 82 int mp_magic; /* sanity check, MP_MAGIC */ 83 } mproc[NR_PROCS]; 84 85 /* Flag values */ 86 #define IN_USE 0x00001 /* set when 'mproc' slot in use */ 87 #define WAITING 0x00002 /* set by WAIT4 system call */ 88 #define ZOMBIE 0x00004 /* waiting for parent to issue WAIT4 call */ 89 #define PROC_STOPPED 0x00008 /* process is stopped in the kernel */ 90 #define ALARM_ON 0x00010 /* set when SIGALRM timer started */ 91 #define EXITING 0x00020 /* set by EXIT, process is now exiting */ 92 #define TOLD_PARENT 0x00040 /* parent wait() completed, ZOMBIE off */ 93 #define TRACE_STOPPED 0x00080 /* set if process stopped for tracing */ 94 #define SIGSUSPENDED 0x00100 /* set by SIGSUSPEND system call */ 95 #define VFS_CALL 0x00400 /* set if waiting for VFS (normal calls) */ 96 #define NEW_PARENT 0x00800 /* process's parent changed during VFS call */ 97 #define UNPAUSED 0x01000 /* VFS has replied to unpause request */ 98 #define PRIV_PROC 0x02000 /* system process, special privileges */ 99 #define PARTIAL_EXEC 0x04000 /* process got a new map but no content */ 100 #define TRACE_EXIT 0x08000 /* tracer is forcing this process to exit */ 101 #define TRACE_ZOMBIE 0x10000 /* waiting for tracer to issue WAIT4 call */ 102 #define DELAY_CALL 0x20000 /* waiting for call before sending signal */ 103 #define TAINTED 0x40000 /* process is 'tainted' */ 104 #define EVENT_CALL 0x80000 /* waiting for process event subscriber */ 105 106 #define MP_MAGIC 0xC0FFEE0 107