etc/services - sync with NetBSD-8
[minix.git] / minix / servers / is / dmp_pm.c
blobae852b5e1d95d1a475fedb6ae2a7beeca49ce281
1 /* This file contains procedures to dump to PM' data structures.
3 * The entry points into this file are
4 * mproc_dmp: display PM process table
6 * Created:
7 * May 11, 2005: by Jorrit N. Herder
8 */
10 #include "inc.h"
11 #include "../pm/mproc.h"
12 #include <minix/timers.h>
13 #include <minix/config.h>
14 #include <minix/type.h>
16 struct mproc mproc[NR_PROCS];
18 /*===========================================================================*
19 * mproc_dmp *
20 *===========================================================================*/
21 static char *flags_str(int flags)
23 static char str[12];
24 str[0] = (flags & WAITING) ? 'W' : '-';
25 str[1] = (flags & ZOMBIE) ? 'Z' : '-';
26 str[2] = (flags & ALARM_ON) ? 'A' : '-';
27 str[3] = (flags & EXITING) ? 'E' : '-';
28 str[4] = (flags & TRACE_STOPPED) ? 'T' : '-';
29 str[5] = (flags & SIGSUSPENDED) ? 'U' : '-';
30 str[6] = (flags & VFS_CALL) ? 'F' : '-';
31 str[7] = (flags & PROC_STOPPED) ? 's' : '-';
32 str[8] = (flags & PRIV_PROC) ? 'p' : '-';
33 str[9] = (flags & PARTIAL_EXEC) ? 'x' : '-';
34 str[10] = (flags & DELAY_CALL) ? 'd' : '-';
35 str[11] = '\0';
37 return str;
40 void
41 mproc_dmp(void)
43 struct mproc *mp;
44 int i, n=0;
45 static int prev_i = 0;
47 if (getsysinfo(PM_PROC_NR, SI_PROC_TAB, mproc, sizeof(mproc)) != OK) {
48 printf("Error obtaining table from PM. Perhaps recompile IS?\n");
49 return;
52 printf("Process manager (PM) process table dump\n");
53 printf("-process- -nr-pnr-tnr- --pid--ppid--pgrp- -uid-- -gid-- -nice- -flags-----\n");
54 for (i=prev_i; i<NR_PROCS; i++) {
55 mp = &mproc[i];
56 if (mp->mp_pid == 0 && i != PM_PROC_NR) continue;
57 if (++n > 22) break;
58 printf("%8.8s %4d%4d%4d %5d %5d %5d ",
59 mp->mp_name, i, mp->mp_parent, mp->mp_tracer, mp->mp_pid, mproc[mp->mp_parent].mp_pid, mp->mp_procgrp);
60 printf("%2d(%2d) %2d(%2d) ",
61 mp->mp_realuid, mp->mp_effuid, mp->mp_realgid, mp->mp_effgid);
62 printf(" %3d %s ",
63 mp->mp_nice, flags_str(mp->mp_flags));
64 printf("\n");
66 if (i >= NR_PROCS) i = 0;
67 else printf("--more--\r");
68 prev_i = i;
71 /*===========================================================================*
72 * sigaction_dmp *
73 *===========================================================================*/
74 void
75 sigaction_dmp(void)
77 struct mproc *mp;
78 int i, n=0;
79 static int prev_i = 0;
80 clock_t uptime;
82 if (getsysinfo(PM_PROC_NR, SI_PROC_TAB, mproc, sizeof(mproc)) != OK) {
83 printf("Error obtaining table from PM. Perhaps recompile IS?\n");
84 return;
86 uptime = getticks();
88 printf("Process manager (PM) signal action dump\n");
89 printf("-process- -nr- --ignore- --catch- --block- -pending- -alarm---\n");
90 for (i=prev_i; i<NR_PROCS; i++) {
91 mp = &mproc[i];
92 if (mp->mp_pid == 0 && i != PM_PROC_NR) continue;
93 if (++n > 22) break;
94 printf("%8.8s %3d ", mp->mp_name, i);
95 printf(" %08x %08x %08x ",
96 mp->mp_ignore.__bits[0], mp->mp_catch.__bits[0],
97 mp->mp_sigmask.__bits[0]);
98 printf("%08x ", mp->mp_sigpending.__bits[0]);
99 if (mp->mp_flags & ALARM_ON) printf("%8lu",
100 (unsigned long) (mp->mp_timer.tmr_exp_time-uptime));
101 else printf(" -");
102 printf("\n");
104 if (i >= NR_PROCS) i = 0;
105 else printf("--more--\r");
106 prev_i = i;