2 * Copyright (c) 1993, 1994, 1995 Rick Sladkey <jrs@world.std.com>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef HAVE_MP_PROCFS
35 static const struct xlat proc_status_flags[] = {
36 { PR_STOPPED, "PR_STOPPED" },
37 { PR_ISTOP, "PR_ISTOP" },
38 { PR_DSTOP, "PR_DSTOP" },
39 { PR_ASLEEP, "PR_ASLEEP" },
40 { PR_FORK, "PR_FORK" },
42 { PR_PTRACE, "PR_PTRACE" },
43 { PR_PCINVAL, "PR_PCINVAL" },
44 { PR_ISSYS, "PR_ISSYS" },
46 { PR_STEP, "PR_STEP" },
52 { PR_ASYNC, "PR_ASYNC" },
55 { PR_PCOMPAT, "PR_PCOMPAT" },
60 static const struct xlat proc_status_why[] = {
61 { PR_REQUESTED, "PR_REQUESTED" },
62 { PR_SIGNALLED, "PR_SIGNALLED" },
63 { PR_SYSENTRY, "PR_SYSENTRY" },
64 { PR_SYSEXIT, "PR_SYSEXIT" },
65 { PR_JOBCONTROL,"PR_JOBCONTROL" },
66 { PR_FAULTED, "PR_FAULTED" },
68 { PR_SUSPENDED, "PR_SUSPENDED" },
71 { PR_CHECKPOINT,"PR_CHECKPOINT" },
76 static const struct xlat proc_run_flags[] = {
78 { PRCFAULT, "PRCFAULT" },
79 { PRSTRACE, "PRSTRACE" },
80 { PRSHOLD, "PRSHOLD" },
81 { PRSFAULT, "PRSFAULT" },
82 { PRSVADDR, "PRSVADDR" },
84 { PRSABORT, "PRSABORT" },
90 proc_ioctl(tcp, code, arg)
107 else if (syserror(tcp))
108 tprintf(", %#x", arg);
109 else if (umove(tcp, arg, &status) < 0)
112 tprintf(", {pr_flags=");
113 printflags(proc_status_flags, status.pr_flags, "PR_???");
115 tprintf(", pr_why=");
116 printxval(proc_status_why, status.pr_why,
119 switch (status.pr_why) {
122 tprintf(", pr_what=");
123 printsignal(status.pr_what);
126 tprintf(", pr_what=%d", status.pr_what);
130 tprintf(", pr_what=SYS_%s",
131 sysent[status.pr_what].sys_name);
140 else if (umove(tcp, arg, &run) < 0)
143 tprintf(", {pr_flags=");
144 printflags(proc_run_flags, run.pr_flags, "PR???");
151 if (umove(tcp, arg, &val) < 0)
155 printflags(proc_status_flags, val, "PR_???");
162 /* takes a pointer to a signal */
163 if (umove(tcp, arg, &val) < 0)
175 /* doesn't take an arg */
183 #endif /* HAVE_MP_PROCFS */
187 #include <sys/pioctl.h>
189 static const struct xlat proc_status_why[] = {
190 { S_EXEC, "S_EXEC" },
194 { S_CORE, "S_CORE" },
195 { S_EXIT, "S_EXIT" },
199 static const struct xlat proc_status_flags[] = {
200 { PF_LINGER, "PF_LINGER" },
201 { PF_ISUGID, "PF_ISUGID" },
206 proc_ioctl(tcp, code, arg)
211 struct procfs_status status;
221 else if (syserror(tcp))
222 tprintf(", %x", arg);
223 else if (umove(tcp, arg, &status) < 0)
226 tprintf(", {state=%d, flags=", status.state);
227 printflags(proc_status_flags, status.flags, "PF_???");
228 tprintf(", events=");
229 printflags(proc_status_why, status.events, "S_???");
231 printxval(proc_status_why, status.why, "S_???");
232 tprintf(", val=%lu}", status.val);
237 printflags(proc_status_why, arg, "S_???");
242 printflags(proc_status_flags, arg, "PF_???");
246 tprintf(", %#x", arg);
247 else if (umove(tcp, arg, &val) < 0)
251 printflags(proc_status_flags, val, "PF_???");