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.
34 static struct xlat proc_status_flags[] = {
35 { PR_STOPPED, "PR_STOPPED" },
36 { PR_ISTOP, "PR_ISTOP" },
37 { PR_DSTOP, "PR_DSTOP" },
38 { PR_ASLEEP, "PR_ASLEEP" },
39 { PR_FORK, "PR_FORK" },
41 { PR_PTRACE, "PR_PTRACE" },
42 { PR_PCINVAL, "PR_PCINVAL" },
43 { PR_ISSYS, "PR_ISSYS" },
45 { PR_STEP, "PR_STEP" },
51 { PR_ASYNC, "PR_ASYNC" },
54 { PR_PCOMPAT, "PR_PCOMPAT" },
59 static struct xlat proc_status_why[] = {
60 { PR_REQUESTED, "PR_REQUESTED" },
61 { PR_SIGNALLED, "PR_SIGNALLED" },
62 { PR_SYSENTRY, "PR_SYSENTRY" },
63 { PR_SYSEXIT, "PR_SYSEXIT" },
64 { PR_JOBCONTROL,"PR_JOBCONTROL" },
65 { PR_FAULTED, "PR_FAULTED" },
67 { PR_SUSPENDED, "PR_SUSPENDED" },
70 { PR_CHECKPOINT,"PR_CHECKPOINT" },
75 static struct xlat proc_run_flags[] = {
77 { PRCFAULT, "PRCFAULT" },
78 { PRSTRACE, "PRSTRACE" },
79 { PRSHOLD, "PRSHOLD" },
80 { PRSFAULT, "PRSFAULT" },
81 { PRSVADDR, "PRSVADDR" },
83 { PRSABORT, "PRSABORT" },
89 proc_ioctl(tcp, code, arg)
106 else if (syserror(tcp))
107 tprintf(", %#x", arg);
108 else if (umove(tcp, arg, &status) < 0)
111 tprintf(", {pr_flags=");
112 if (!printflags(proc_status_flags, status.pr_flags))
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 if (!printflags(proc_run_flags, run.pr_flags))
152 if (umove(tcp, arg, &val) < 0)
156 if (!printflags(proc_status_flags, val))
164 /* takes a pointer to a signal */
165 if (umove(tcp, arg, &val) < 0)
177 /* doesn't take an arg */