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.
35 static 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 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 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 if (!printflags(proc_status_flags, status.pr_flags))
116 tprintf(", pr_why=");
117 printxval(proc_status_why, status.pr_why,
120 switch (status.pr_why) {
123 tprintf(", pr_what=");
124 printsignal(status.pr_what);
127 tprintf(", pr_what=%d", status.pr_what);
131 tprintf(", pr_what=SYS_%s",
132 sysent[status.pr_what].sys_name);
141 else if (umove(tcp, arg, &run) < 0)
144 tprintf(", {pr_flags=");
145 if (!printflags(proc_run_flags, run.pr_flags))
153 if (umove(tcp, arg, &val) < 0)
157 if (!printflags(proc_status_flags, val))
165 /* takes a pointer to a signal */
166 if (umove(tcp, arg, &val) < 0)
178 /* doesn't take an arg */