Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl> |
| 3 | * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl> |
| 4 | * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com> |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 5 | * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl> |
| 6 | * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation |
| 7 | * Linux for s390 port by D.J. Barrow |
| 8 | * <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 9 | * All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer. |
| 16 | * 2. Redistributions in binary form must reproduce the above copyright |
| 17 | * notice, this list of conditions and the following disclaimer in the |
| 18 | * documentation and/or other materials provided with the distribution. |
| 19 | * 3. The name of the author may not be used to endorse or promote products |
| 20 | * derived from this software without specific prior written permission. |
| 21 | * |
| 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | * |
| 33 | * $Id$ |
| 34 | */ |
| 35 | |
| 36 | #include "defs.h" |
| 37 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 38 | #include <signal.h> |
| 39 | #include <sys/user.h> |
| 40 | #include <fcntl.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 41 | |
| 42 | #ifdef SVR4 |
| 43 | #include <sys/ucontext.h> |
| 44 | #endif /* SVR4 */ |
| 45 | |
Wichert Akkerman | 36915a1 | 1999-07-13 15:45:02 +0000 | [diff] [blame] | 46 | #ifdef HAVE_SYS_REG_H |
| 47 | # include <sys/reg.h> |
Wichert Akkerman | 15dea97 | 1999-10-06 13:06:34 +0000 | [diff] [blame] | 48 | #ifndef PTRACE_PEEKUSR |
Wichert Akkerman | 36915a1 | 1999-07-13 15:45:02 +0000 | [diff] [blame] | 49 | # define PTRACE_PEEKUSR PTRACE_PEEKUSER |
Wichert Akkerman | 15dea97 | 1999-10-06 13:06:34 +0000 | [diff] [blame] | 50 | #endif |
| 51 | #ifndef PTRACE_POKEUSR |
Wichert Akkerman | 36915a1 | 1999-07-13 15:45:02 +0000 | [diff] [blame] | 52 | # define PTRACE_POKEUSR PTRACE_POKEUSER |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 53 | #endif |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 54 | #elif defined(HAVE_LINUX_PTRACE_H) |
| 55 | #undef PTRACE_SYSCALL |
| 56 | #include <linux/ptrace.h> |
Wichert Akkerman | 15dea97 | 1999-10-06 13:06:34 +0000 | [diff] [blame] | 57 | #endif |
Wichert Akkerman | 36915a1 | 1999-07-13 15:45:02 +0000 | [diff] [blame] | 58 | |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 59 | |
Wichert Akkerman | 36915a1 | 1999-07-13 15:45:02 +0000 | [diff] [blame] | 60 | #ifdef LINUX |
| 61 | |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 62 | #ifdef IA64 |
| 63 | # include <asm/ptrace_offsets.h> |
| 64 | #endif /* !IA64 */ |
| 65 | |
Wichert Akkerman | 00a82ee | 2001-03-28 20:29:17 +0000 | [diff] [blame] | 66 | #if HAVE_ASM_REG_H |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 67 | #ifdef SPARC |
Wichert Akkerman | 00a82ee | 2001-03-28 20:29:17 +0000 | [diff] [blame] | 68 | # define fpq kernel_fpq |
| 69 | # define fq kernel_fq |
| 70 | # define fpu kernel_fpu |
| 71 | #endif |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 72 | #include <asm/reg.h> |
Wichert Akkerman | 00a82ee | 2001-03-28 20:29:17 +0000 | [diff] [blame] | 73 | #ifdef SPARC |
| 74 | # undef fpq |
| 75 | # undef fq |
| 76 | # undef fpu |
| 77 | #endif |
| 78 | |
| 79 | #endif /* HAVE_ASM_REG_H */ |
| 80 | #ifdef HAVE_ASM_SIGCONTEXT_H |
| 81 | #ifdef SPARC |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 82 | typedef struct { |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 83 | struct regs si_regs; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 84 | int si_mask; |
| 85 | } m_siginfo_t; |
Wichert Akkerman | 00a82ee | 2001-03-28 20:29:17 +0000 | [diff] [blame] | 86 | #else |
| 87 | #include <asm/sigcontext.h> |
| 88 | #endif /* SPARC */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 89 | #else /* !HAVE_ASM_SIGCONTEXT_H */ |
| 90 | #ifdef I386 |
| 91 | struct sigcontext_struct { |
| 92 | unsigned short gs, __gsh; |
| 93 | unsigned short fs, __fsh; |
| 94 | unsigned short es, __esh; |
| 95 | unsigned short ds, __dsh; |
| 96 | unsigned long edi; |
| 97 | unsigned long esi; |
| 98 | unsigned long ebp; |
| 99 | unsigned long esp; |
| 100 | unsigned long ebx; |
| 101 | unsigned long edx; |
| 102 | unsigned long ecx; |
| 103 | unsigned long eax; |
| 104 | unsigned long trapno; |
| 105 | unsigned long err; |
| 106 | unsigned long eip; |
| 107 | unsigned short cs, __csh; |
| 108 | unsigned long eflags; |
| 109 | unsigned long esp_at_signal; |
| 110 | unsigned short ss, __ssh; |
| 111 | unsigned long i387; |
| 112 | unsigned long oldmask; |
| 113 | unsigned long cr2; |
| 114 | }; |
| 115 | #else /* !I386 */ |
| 116 | #ifdef M68K |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 117 | struct sigcontext |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 118 | { |
| 119 | unsigned long sc_mask; |
| 120 | unsigned long sc_usp; |
| 121 | unsigned long sc_d0; |
| 122 | unsigned long sc_d1; |
| 123 | unsigned long sc_a0; |
| 124 | unsigned long sc_a1; |
| 125 | unsigned short sc_sr; |
| 126 | unsigned long sc_pc; |
| 127 | unsigned short sc_formatvec; |
| 128 | }; |
| 129 | #endif /* M68K */ |
| 130 | #endif /* !I386 */ |
| 131 | #endif /* !HAVE_ASM_SIGCONTEXT_H */ |
| 132 | #ifndef NSIG |
| 133 | #define NSIG 32 |
| 134 | #endif |
| 135 | #ifdef ARM |
| 136 | #undef NSIG |
| 137 | #define NSIG 32 |
| 138 | #endif |
| 139 | #endif /* LINUX */ |
| 140 | |
| 141 | char *signalent0[] = { |
| 142 | #include "signalent.h" |
| 143 | }; |
| 144 | int nsignals0 = sizeof signalent0 / sizeof signalent0[0]; |
| 145 | |
| 146 | #if SUPPORTED_PERSONALITIES >= 2 |
| 147 | char *signalent1[] = { |
| 148 | #include "signalent1.h" |
| 149 | }; |
| 150 | int nsignals1 = sizeof signalent1 / sizeof signalent1[0]; |
| 151 | #endif /* SUPPORTED_PERSONALITIES >= 2 */ |
| 152 | |
| 153 | #if SUPPORTED_PERSONALITIES >= 3 |
| 154 | char *signalent2[] = { |
| 155 | #include "signalent2.h" |
| 156 | }; |
| 157 | int nsignals2 = sizeof signalent2 / sizeof signalent2[0]; |
| 158 | #endif /* SUPPORTED_PERSONALITIES >= 3 */ |
| 159 | |
| 160 | char **signalent; |
| 161 | int nsignals; |
| 162 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 163 | #if defined(SUNOS4) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 164 | |
| 165 | static struct xlat sigvec_flags[] = { |
| 166 | { SV_ONSTACK, "SV_ONSTACK" }, |
| 167 | { SV_INTERRUPT, "SV_INTERRUPT" }, |
| 168 | { SV_RESETHAND, "SV_RESETHAND" }, |
| 169 | { SA_NOCLDSTOP, "SA_NOCLDSTOP" }, |
| 170 | { 0, NULL }, |
| 171 | }; |
| 172 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 173 | #endif /* SUNOS4 || FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 174 | |
| 175 | #ifdef HAVE_SIGACTION |
| 176 | |
| 177 | static struct xlat sigact_flags[] = { |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 178 | #ifdef SA_RESTORER |
| 179 | { SA_RESTORER, "SA_RESTORER" }, |
| 180 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 181 | #ifdef SA_STACK |
| 182 | { SA_STACK, "SA_STACK" }, |
| 183 | #endif |
| 184 | #ifdef SA_RESTART |
| 185 | { SA_RESTART, "SA_RESTART" }, |
| 186 | #endif |
| 187 | #ifdef SA_INTERRUPT |
| 188 | { SA_INTERRUPT, "SA_INTERRUPT" }, |
| 189 | #endif |
| 190 | #ifdef SA_NOMASK |
| 191 | { SA_NOMASK, "SA_NOMASK" }, |
| 192 | #endif |
| 193 | #ifdef SA_ONESHOT |
| 194 | { SA_ONESHOT, "SA_ONESHOT" }, |
| 195 | #endif |
| 196 | #ifdef SA_SIGINFO |
| 197 | { SA_SIGINFO, "SA_SIGINFO" }, |
| 198 | #endif |
| 199 | #ifdef SA_RESETHAND |
| 200 | { SA_RESETHAND, "SA_RESETHAND" }, |
| 201 | #endif |
| 202 | #ifdef SA_ONSTACK |
| 203 | { SA_ONSTACK, "SA_ONSTACK" }, |
| 204 | #endif |
| 205 | #ifdef SA_NODEFER |
| 206 | { SA_NODEFER, "SA_NODEFER" }, |
| 207 | #endif |
| 208 | #ifdef SA_NOCLDSTOP |
| 209 | { SA_NOCLDSTOP, "SA_NOCLDSTOP" }, |
| 210 | #endif |
| 211 | #ifdef SA_NOCLDWAIT |
| 212 | { SA_NOCLDWAIT, "SA_NOCLDWAIT" }, |
| 213 | #endif |
| 214 | #ifdef _SA_BSDCALL |
| 215 | { _SA_BSDCALL, "_SA_BSDCALL" }, |
| 216 | #endif |
| 217 | { 0, NULL }, |
| 218 | }; |
| 219 | |
| 220 | static struct xlat sigprocmaskcmds[] = { |
| 221 | { SIG_BLOCK, "SIG_BLOCK" }, |
| 222 | { SIG_UNBLOCK, "SIG_UNBLOCK" }, |
| 223 | { SIG_SETMASK, "SIG_SETMASK" }, |
| 224 | #ifdef SIG_SETMASK32 |
| 225 | { SIG_SETMASK32,"SIG_SETMASK32" }, |
| 226 | #endif |
| 227 | { 0, NULL }, |
| 228 | }; |
| 229 | |
| 230 | #endif /* HAVE_SIGACTION */ |
| 231 | |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 232 | /* Anonymous realtime signals. */ |
| 233 | /* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a |
| 234 | constant. This is what we want. Otherwise, just use SIGRTMIN. */ |
| 235 | #ifdef SIGRTMIN |
| 236 | #ifndef __SIGRTMIN |
| 237 | #define __SIGRTMIN SIGRTMIN |
| 238 | #define __SIGRTMAX SIGRTMAX /* likewise */ |
| 239 | #endif |
| 240 | #endif |
| 241 | |
| 242 | char * |
| 243 | signame(sig) |
| 244 | int sig; |
| 245 | { |
| 246 | static char buf[30]; |
| 247 | if (sig < nsignals) { |
| 248 | return signalent[sig]; |
| 249 | #ifdef SIGRTMIN |
Nate Sammons | 3080aa4 | 1999-03-30 00:16:41 +0000 | [diff] [blame] | 250 | } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 251 | sprintf(buf, "SIGRT_%ld", (long)(sig - __SIGRTMIN)); |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 252 | return buf; |
| 253 | #endif /* SIGRTMIN */ |
| 254 | } else { |
| 255 | sprintf(buf, "%d", sig); |
| 256 | return buf; |
| 257 | } |
| 258 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 259 | |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 260 | #ifndef UNIXWARE |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 261 | static void |
| 262 | long_to_sigset(l, s) |
| 263 | long l; |
| 264 | sigset_t *s; |
| 265 | { |
| 266 | sigemptyset(s); |
| 267 | *(long *)s = l; |
| 268 | } |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 269 | #endif |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 270 | |
| 271 | static int |
| 272 | copy_sigset_len(tcp, addr, s, len) |
| 273 | struct tcb *tcp; |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 274 | long addr; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 275 | sigset_t *s; |
| 276 | int len; |
| 277 | { |
| 278 | if (len > sizeof(*s)) |
| 279 | len = sizeof(*s); |
| 280 | sigemptyset(s); |
| 281 | if (umoven(tcp, addr, len, (char *)s) < 0) |
| 282 | return -1; |
| 283 | return 0; |
| 284 | } |
| 285 | |
| 286 | #ifdef LINUX |
| 287 | /* Original sigset is unsigned long */ |
| 288 | #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(long)) |
| 289 | #else |
| 290 | #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(sigset_t)) |
| 291 | #endif |
| 292 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 293 | static char * |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 294 | sprintsigmask(s, mask, rt) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 295 | char *s; |
| 296 | sigset_t *mask; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 297 | int rt; /* set might include realtime sigs */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 298 | { |
| 299 | int i, nsigs; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 300 | int maxsigs; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 301 | char *format; |
| 302 | static char outstr[256]; |
| 303 | |
| 304 | strcpy(outstr, s); |
| 305 | s = outstr + strlen(outstr); |
| 306 | nsigs = 0; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 307 | maxsigs = nsignals; |
| 308 | #ifdef __SIGRTMAX |
| 309 | if (rt) |
| 310 | maxsigs = __SIGRTMAX; /* instead */ |
| 311 | #endif |
| 312 | for (i = 1; i < maxsigs; i++) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 313 | if (sigismember(mask, i) == 1) |
| 314 | nsigs++; |
| 315 | } |
| 316 | if (nsigs >= nsignals * 2 / 3) { |
| 317 | *s++ = '~'; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 318 | for (i = 1; i < maxsigs; i++) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 319 | switch (sigismember(mask, i)) { |
| 320 | case 1: |
| 321 | sigdelset(mask, i); |
| 322 | break; |
| 323 | case 0: |
| 324 | sigaddset(mask, i); |
| 325 | break; |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | format = "%s"; |
| 330 | *s++ = '['; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 331 | for (i = 1; i < maxsigs; i++) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 332 | if (sigismember(mask, i) == 1) { |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 333 | /* real-time signals on solaris don't have |
| 334 | * signalent entries |
| 335 | */ |
| 336 | if (i < nsignals) { |
| 337 | sprintf(s, format, signalent[i] + 3); |
| 338 | } |
| 339 | else { |
| 340 | char tsig[32]; |
| 341 | sprintf(tsig, "%u", i); |
| 342 | sprintf(s, format, tsig); |
| 343 | } |
| 344 | s += strlen(s); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 345 | format = " %s"; |
| 346 | } |
| 347 | } |
| 348 | *s++ = ']'; |
| 349 | *s = '\0'; |
| 350 | return outstr; |
| 351 | } |
| 352 | |
| 353 | static void |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 354 | printsigmask(mask, rt) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 355 | sigset_t *mask; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 356 | int rt; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 357 | { |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 358 | tprintf("%s", sprintsigmask("", mask, rt)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | void |
| 362 | printsignal(nr) |
| 363 | int nr; |
| 364 | { |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 365 | tprintf(signame(nr)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 366 | } |
| 367 | |
| 368 | /* |
| 369 | * Check process TCP for the disposition of signal SIG. |
| 370 | * Return 1 if the process would somehow manage to survive signal SIG, |
| 371 | * else return 0. This routine will never be called with SIGKILL. |
| 372 | */ |
| 373 | int |
| 374 | sigishandled(tcp, sig) |
| 375 | struct tcb *tcp; |
| 376 | int sig; |
| 377 | { |
| 378 | #ifdef LINUX |
| 379 | int sfd; |
| 380 | char sname[32]; |
| 381 | char buf[1024]; |
| 382 | char *s; |
| 383 | int i; |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 384 | unsigned int signalled, blocked, ignored, caught; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 385 | |
| 386 | /* This is incredibly costly but it's worth it. */ |
| 387 | sprintf(sname, "/proc/%d/stat", tcp->pid); |
| 388 | if ((sfd = open(sname, O_RDONLY)) == -1) { |
| 389 | perror(sname); |
| 390 | return 1; |
| 391 | } |
| 392 | i = read(sfd, buf, 1024); |
| 393 | buf[i] = '\0'; |
| 394 | close(sfd); |
| 395 | /* |
| 396 | * Skip the extraneous fields. This loses if the |
| 397 | * command name has any spaces in it. So be it. |
| 398 | */ |
| 399 | for (i = 0, s = buf; i < 30; i++) { |
| 400 | while (*++s != ' ') { |
| 401 | if (!*s) |
| 402 | break; |
| 403 | } |
| 404 | } |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 405 | if (sscanf(s, "%u%u%u%u", |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 406 | &signalled, &blocked, &ignored, &caught) != 4) { |
| 407 | fprintf(stderr, "/proc/pid/stat format error\n"); |
| 408 | return 1; |
| 409 | } |
| 410 | #ifdef DEBUG |
| 411 | fprintf(stderr, "sigs: %08x %08x %08x %08x\n", |
| 412 | signalled, blocked, ignored, caught); |
| 413 | #endif |
| 414 | if ((ignored & sigmask(sig)) || (caught & sigmask(sig))) |
| 415 | return 1; |
| 416 | #endif /* LINUX */ |
| 417 | |
| 418 | #ifdef SUNOS4 |
| 419 | void (*u_signal)(); |
| 420 | |
| 421 | if (upeek(tcp->pid, uoff(u_signal[0]) + sig*sizeof(u_signal), |
| 422 | (long *) &u_signal) < 0) { |
| 423 | return 0; |
| 424 | } |
| 425 | if (u_signal != SIG_DFL) |
| 426 | return 1; |
| 427 | #endif /* SUNOS4 */ |
| 428 | |
| 429 | #ifdef SVR4 |
| 430 | /* |
| 431 | * Since procfs doesn't interfere with wait I think it is safe |
| 432 | * to punt on this question. If not, the information is there. |
| 433 | */ |
| 434 | return 1; |
| 435 | #else /* !SVR4 */ |
| 436 | switch (sig) { |
| 437 | case SIGCONT: |
| 438 | case SIGSTOP: |
| 439 | case SIGTSTP: |
| 440 | case SIGTTIN: |
| 441 | case SIGTTOU: |
| 442 | case SIGCHLD: |
| 443 | case SIGIO: |
| 444 | #if defined(SIGURG) && SIGURG != SIGIO |
| 445 | case SIGURG: |
| 446 | #endif |
| 447 | case SIGWINCH: |
| 448 | /* Gloria Gaynor says ... */ |
| 449 | return 1; |
| 450 | default: |
| 451 | break; |
| 452 | } |
| 453 | return 0; |
| 454 | #endif /* !SVR4 */ |
| 455 | } |
| 456 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 457 | #if defined(SUNOS4) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 458 | |
| 459 | int |
| 460 | sys_sigvec(tcp) |
| 461 | struct tcb *tcp; |
| 462 | { |
| 463 | struct sigvec sv; |
| 464 | long addr; |
| 465 | |
| 466 | if (entering(tcp)) { |
| 467 | printsignal(tcp->u_arg[0]); |
| 468 | tprintf(", "); |
| 469 | addr = tcp->u_arg[1]; |
| 470 | } else { |
| 471 | addr = tcp->u_arg[2]; |
| 472 | } |
| 473 | if (addr == 0) |
| 474 | tprintf("NULL"); |
| 475 | else if (!verbose(tcp)) |
| 476 | tprintf("%#lx", addr); |
| 477 | else if (umove(tcp, addr, &sv) < 0) |
| 478 | tprintf("{...}"); |
| 479 | else { |
| 480 | switch ((int) sv.sv_handler) { |
| 481 | case (int) SIG_ERR: |
| 482 | tprintf("{SIG_ERR}"); |
| 483 | break; |
| 484 | case (int) SIG_DFL: |
| 485 | tprintf("{SIG_DFL}"); |
| 486 | break; |
| 487 | case (int) SIG_IGN: |
| 488 | if (tcp->u_arg[0] == SIGTRAP) { |
| 489 | tcp->flags |= TCB_SIGTRAPPED; |
| 490 | kill(tcp->pid, SIGSTOP); |
| 491 | } |
| 492 | tprintf("{SIG_IGN}"); |
| 493 | break; |
| 494 | case (int) SIG_HOLD: |
| 495 | if (tcp->u_arg[0] == SIGTRAP) { |
| 496 | tcp->flags |= TCB_SIGTRAPPED; |
| 497 | kill(tcp->pid, SIGSTOP); |
| 498 | } |
| 499 | tprintf("SIG_HOLD"); |
| 500 | break; |
| 501 | default: |
| 502 | if (tcp->u_arg[0] == SIGTRAP) { |
| 503 | tcp->flags |= TCB_SIGTRAPPED; |
| 504 | kill(tcp->pid, SIGSTOP); |
| 505 | } |
| 506 | tprintf("{%#lx, ", (unsigned long) sv.sv_handler); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 507 | printsigmask(&sv.sv_mask, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 508 | tprintf(", "); |
| 509 | if (!printflags(sigvec_flags, sv.sv_flags)) |
| 510 | tprintf("0"); |
| 511 | tprintf("}"); |
| 512 | } |
| 513 | } |
| 514 | if (entering(tcp)) |
| 515 | tprintf(", "); |
| 516 | return 0; |
| 517 | } |
| 518 | |
| 519 | int |
| 520 | sys_sigpause(tcp) |
| 521 | struct tcb *tcp; |
| 522 | { |
| 523 | if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */ |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 524 | sigset_t sigm; |
| 525 | long_to_sigset(tcp->u_arg[0], &sigm); |
| 526 | printsigmask(&sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 527 | } |
| 528 | return 0; |
| 529 | } |
| 530 | |
| 531 | int |
| 532 | sys_sigstack(tcp) |
| 533 | struct tcb *tcp; |
| 534 | { |
| 535 | struct sigstack ss; |
| 536 | long addr; |
| 537 | |
| 538 | if (entering(tcp)) |
| 539 | addr = tcp->u_arg[0]; |
| 540 | else |
| 541 | addr = tcp->u_arg[1]; |
| 542 | if (addr == 0) |
| 543 | tprintf("NULL"); |
| 544 | else if (umove(tcp, addr, &ss) < 0) |
| 545 | tprintf("%#lx", addr); |
| 546 | else { |
| 547 | tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp); |
| 548 | tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO"); |
| 549 | } |
| 550 | if (entering(tcp)) |
| 551 | tprintf(", "); |
| 552 | return 0; |
| 553 | } |
| 554 | |
| 555 | int |
| 556 | sys_sigcleanup(tcp) |
| 557 | struct tcb *tcp; |
| 558 | { |
| 559 | return 0; |
| 560 | } |
| 561 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 562 | #endif /* SUNOS4 || FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 563 | |
| 564 | #ifndef SVR4 |
| 565 | |
| 566 | int |
| 567 | sys_sigsetmask(tcp) |
| 568 | struct tcb *tcp; |
| 569 | { |
| 570 | if (entering(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 571 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 572 | long_to_sigset(tcp->u_arg[0], &sigm); |
| 573 | printsigmask(&sigm, 0); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 574 | #ifndef USE_PROCFS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 575 | if ((tcp->u_arg[0] & sigmask(SIGTRAP))) { |
| 576 | /* Mark attempt to block SIGTRAP */ |
| 577 | tcp->flags |= TCB_SIGTRAPPED; |
| 578 | /* Send unblockable signal */ |
| 579 | kill(tcp->pid, SIGSTOP); |
| 580 | } |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 581 | #endif /* !USE_PROCFS */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 582 | } |
| 583 | else if (!syserror(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 584 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 585 | long_to_sigset(tcp->u_rval, &sigm); |
| 586 | tcp->auxstr = sprintsigmask("old mask ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 587 | |
| 588 | return RVAL_HEX | RVAL_STR; |
| 589 | } |
| 590 | return 0; |
| 591 | } |
| 592 | |
| 593 | int |
| 594 | sys_sigblock(tcp) |
| 595 | struct tcb *tcp; |
| 596 | { |
| 597 | return sys_sigsetmask(tcp); |
| 598 | } |
| 599 | |
| 600 | #endif /* !SVR4 */ |
| 601 | |
| 602 | #ifdef HAVE_SIGACTION |
| 603 | |
| 604 | #ifdef LINUX |
| 605 | struct old_sigaction { |
| 606 | __sighandler_t __sa_handler; |
| 607 | unsigned long sa_mask; |
| 608 | unsigned long sa_flags; |
| 609 | void (*sa_restorer)(void); |
| 610 | }; |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 611 | #define SA_HANDLER __sa_handler |
| 612 | #endif /* LINUX */ |
| 613 | |
| 614 | #ifndef SA_HANDLER |
| 615 | #define SA_HANDLER sa_handler |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 616 | #endif |
| 617 | |
| 618 | int |
| 619 | sys_sigaction(tcp) |
| 620 | struct tcb *tcp; |
| 621 | { |
| 622 | long addr; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 623 | #ifdef LINUX |
John Hughes | 1e4cb34 | 2001-03-06 09:25:46 +0000 | [diff] [blame] | 624 | sigset_t sigset; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 625 | struct old_sigaction sa; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 626 | #else |
| 627 | struct sigaction sa; |
| 628 | #endif |
| 629 | |
| 630 | |
| 631 | if (entering(tcp)) { |
| 632 | printsignal(tcp->u_arg[0]); |
| 633 | tprintf(", "); |
| 634 | addr = tcp->u_arg[1]; |
| 635 | } else |
| 636 | addr = tcp->u_arg[2]; |
| 637 | if (addr == 0) |
| 638 | tprintf("NULL"); |
| 639 | else if (!verbose(tcp)) |
| 640 | tprintf("%#lx", addr); |
| 641 | else if (umove(tcp, addr, &sa) < 0) |
| 642 | tprintf("{...}"); |
| 643 | else { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 644 | switch ((long) sa.SA_HANDLER) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 645 | case (long) SIG_ERR: |
| 646 | tprintf("{SIG_ERR}"); |
| 647 | break; |
| 648 | case (long) SIG_DFL: |
| 649 | tprintf("{SIG_DFL}"); |
| 650 | break; |
| 651 | case (long) SIG_IGN: |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 652 | #ifndef USE_PROCFS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 653 | if (tcp->u_arg[0] == SIGTRAP) { |
| 654 | tcp->flags |= TCB_SIGTRAPPED; |
| 655 | kill(tcp->pid, SIGSTOP); |
| 656 | } |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 657 | #endif /* !USE_PROCFS */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 658 | tprintf("{SIG_IGN}"); |
| 659 | break; |
| 660 | default: |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 661 | #ifndef USE_PROCFS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 662 | if (tcp->u_arg[0] == SIGTRAP) { |
| 663 | tcp->flags |= TCB_SIGTRAPPED; |
| 664 | kill(tcp->pid, SIGSTOP); |
| 665 | } |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 666 | #endif /* !USE_PROCFS */ |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 667 | tprintf("{%#lx, ", (long) sa.SA_HANDLER); |
Wichert Akkerman | 48214be | 1999-11-26 09:55:42 +0000 | [diff] [blame] | 668 | #ifndef LINUX |
| 669 | printsigmask (&sa.sa_mask, 0); |
| 670 | #else |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 671 | long_to_sigset(sa.sa_mask, &sigset); |
| 672 | printsigmask(&sigset, 0); |
Wichert Akkerman | 48214be | 1999-11-26 09:55:42 +0000 | [diff] [blame] | 673 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 674 | tprintf(", "); |
| 675 | if (!printflags(sigact_flags, sa.sa_flags)) |
| 676 | tprintf("0"); |
| 677 | tprintf("}"); |
| 678 | } |
| 679 | } |
| 680 | if (entering(tcp)) |
| 681 | tprintf(", "); |
| 682 | #ifdef LINUX |
| 683 | else |
| 684 | tprintf(", %#lx", (unsigned long) sa.sa_restorer); |
| 685 | #endif |
| 686 | return 0; |
| 687 | } |
| 688 | |
| 689 | int |
| 690 | sys_signal(tcp) |
| 691 | struct tcb *tcp; |
| 692 | { |
| 693 | if (entering(tcp)) { |
| 694 | printsignal(tcp->u_arg[0]); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 695 | tprintf(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 696 | switch (tcp->u_arg[1]) { |
| 697 | case (int) SIG_ERR: |
| 698 | tprintf("SIG_ERR"); |
| 699 | break; |
| 700 | case (int) SIG_DFL: |
| 701 | tprintf("SIG_DFL"); |
| 702 | break; |
| 703 | case (int) SIG_IGN: |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 704 | #ifndef USE_PROCFS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 705 | if (tcp->u_arg[0] == SIGTRAP) { |
| 706 | tcp->flags |= TCB_SIGTRAPPED; |
| 707 | kill(tcp->pid, SIGSTOP); |
| 708 | } |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 709 | #endif /* !USE_PROCFS */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 710 | tprintf("SIG_IGN"); |
| 711 | break; |
| 712 | default: |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 713 | #ifndef USE_PROCFS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 714 | if (tcp->u_arg[0] == SIGTRAP) { |
| 715 | tcp->flags |= TCB_SIGTRAPPED; |
| 716 | kill(tcp->pid, SIGSTOP); |
| 717 | } |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 718 | #endif /* !USE_PROCFS */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 719 | tprintf("%#lx", tcp->u_arg[1]); |
| 720 | } |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 721 | return 0; |
| 722 | } |
| 723 | else { |
| 724 | switch (tcp->u_rval) { |
| 725 | case (int) SIG_ERR: |
| 726 | tcp->auxstr = "SIG_ERR"; break; |
| 727 | case (int) SIG_DFL: |
| 728 | tcp->auxstr = "SIG_DFL"; break; |
| 729 | case (int) SIG_IGN: |
| 730 | tcp->auxstr = "SIG_IGN"; break; |
| 731 | default: |
| 732 | tcp->auxstr = NULL; |
| 733 | } |
| 734 | return RVAL_HEX | RVAL_STR; |
| 735 | } |
| 736 | } |
| 737 | |
| 738 | int |
| 739 | sys_sighold(tcp) |
| 740 | struct tcb *tcp; |
| 741 | { |
| 742 | if (entering(tcp)) { |
| 743 | printsignal(tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 744 | } |
| 745 | return 0; |
| 746 | } |
| 747 | |
| 748 | #endif /* HAVE_SIGACTION */ |
| 749 | |
| 750 | #ifdef LINUX |
| 751 | |
| 752 | int |
| 753 | sys_sigreturn(tcp) |
| 754 | struct tcb *tcp; |
| 755 | { |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 756 | #ifdef S390 |
| 757 | long usp; |
| 758 | struct sigcontext_struct sc; |
| 759 | |
| 760 | if (entering(tcp)) { |
| 761 | tcp->u_arg[0] = 0; |
| 762 | if (upeek(tcp->pid,PT_GPR15,&usp)<0) |
| 763 | return 0; |
| 764 | if (umove(tcp, usp+__SIGNAL_FRAMESIZE, &sc) < 0) |
| 765 | return 0; |
| 766 | tcp->u_arg[0] = 1; |
| 767 | memcpy(&tcp->u_arg[1],&sc.oldmask[0],sizeof(sigset_t)); |
| 768 | } else { |
| 769 | tcp->u_rval = tcp->u_error = 0; |
| 770 | if (tcp->u_arg[0] == 0) |
| 771 | return 0; |
| 772 | tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1]); |
| 773 | return RVAL_NONE | RVAL_STR; |
| 774 | } |
| 775 | return 0; |
| 776 | #else |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 777 | #ifdef I386 |
| 778 | long esp; |
| 779 | struct sigcontext_struct sc; |
| 780 | |
| 781 | if (entering(tcp)) { |
| 782 | tcp->u_arg[0] = 0; |
| 783 | if (upeek(tcp->pid, 4*UESP, &esp) < 0) |
| 784 | return 0; |
| 785 | if (umove(tcp, esp, &sc) < 0) |
| 786 | return 0; |
| 787 | tcp->u_arg[0] = 1; |
| 788 | tcp->u_arg[1] = sc.oldmask; |
| 789 | } |
| 790 | else { |
| 791 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 792 | long_to_sigset(tcp->u_arg[1], &sigm); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 793 | tcp->u_rval = tcp->u_error = 0; |
| 794 | if (tcp->u_arg[0] == 0) |
| 795 | return 0; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 796 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 797 | return RVAL_NONE | RVAL_STR; |
| 798 | } |
| 799 | return 0; |
| 800 | #else /* !I386 */ |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 801 | #ifdef IA64 |
| 802 | struct sigcontext sc; |
| 803 | long sp; |
| 804 | |
| 805 | if (entering(tcp)) { |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 806 | /* offset of sigcontext in the kernel's sigframe structure: */ |
| 807 | # define SIGFRAME_SC_OFFSET 0x90 |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 808 | tcp->u_arg[0] = 0; |
| 809 | if (upeek(tcp->pid, PT_R12, &sp) < 0) |
| 810 | return 0; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 811 | if (umove(tcp, sp + 16 + SIGFRAME_SC_OFFSET, &sc) < 0) |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 812 | return 0; |
| 813 | tcp->u_arg[0] = 1; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 814 | memcpy(tcp->u_arg + 1, &sc.sc_mask, sizeof(sc.sc_mask)); |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 815 | } |
| 816 | else { |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 817 | sigset_t sigm; |
| 818 | |
| 819 | memcpy(&sigm, tcp->u_arg + 1, sizeof (sigm)); |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 820 | tcp->u_rval = tcp->u_error = 0; |
| 821 | if (tcp->u_arg[0] == 0) |
| 822 | return 0; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 823 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 824 | return RVAL_NONE | RVAL_STR; |
| 825 | } |
| 826 | return 0; |
| 827 | #else /* !IA64 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 828 | #ifdef POWERPC |
| 829 | long esp; |
| 830 | struct sigcontext_struct sc; |
| 831 | |
| 832 | if (entering(tcp)) { |
| 833 | tcp->u_arg[0] = 0; |
| 834 | if (upeek(tcp->pid, 4*PT_R1, &esp) < 0) |
| 835 | return 0; |
| 836 | if (umove(tcp, esp, &sc) < 0) |
| 837 | return 0; |
| 838 | tcp->u_arg[0] = 1; |
| 839 | tcp->u_arg[1] = sc.oldmask; |
| 840 | } |
| 841 | else { |
| 842 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 843 | long_to_sigset(tcp->u_arg[1], &sigm); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 844 | tcp->u_rval = tcp->u_error = 0; |
| 845 | if (tcp->u_arg[0] == 0) |
| 846 | return 0; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 847 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 848 | return RVAL_NONE | RVAL_STR; |
| 849 | } |
| 850 | return 0; |
| 851 | #else /* !POWERPC */ |
| 852 | #ifdef M68K |
| 853 | long usp; |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 854 | struct sigcontext sc; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 855 | |
| 856 | if (entering(tcp)) { |
| 857 | tcp->u_arg[0] = 0; |
| 858 | if (upeek(tcp->pid, 4*PT_USP, &usp) < 0) |
| 859 | return 0; |
| 860 | if (umove(tcp, usp, &sc) < 0) |
| 861 | return 0; |
| 862 | tcp->u_arg[0] = 1; |
| 863 | tcp->u_arg[1] = sc.sc_mask; |
| 864 | } |
| 865 | else { |
| 866 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 867 | long_to_sigset(tcp->u_arg[1], &sigm); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 868 | tcp->u_rval = tcp->u_error = 0; |
| 869 | if (tcp->u_arg[0] == 0) |
| 870 | return 0; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 871 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 872 | return RVAL_NONE | RVAL_STR; |
| 873 | } |
| 874 | return 0; |
| 875 | #else /* !M68K */ |
| 876 | #ifdef ALPHA |
| 877 | long fp; |
| 878 | struct sigcontext_struct sc; |
| 879 | |
| 880 | if (entering(tcp)) { |
| 881 | tcp->u_arg[0] = 0; |
| 882 | if (upeek(tcp->pid, REG_FP, &fp) < 0) |
| 883 | return 0; |
| 884 | if (umove(tcp, fp, &sc) < 0) |
| 885 | return 0; |
| 886 | tcp->u_arg[0] = 1; |
| 887 | tcp->u_arg[1] = sc.sc_mask; |
| 888 | } |
| 889 | else { |
| 890 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 891 | long_to_sigset(tcp->u_arg[1], &sigm); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 892 | tcp->u_rval = tcp->u_error = 0; |
| 893 | if (tcp->u_arg[0] == 0) |
| 894 | return 0; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 895 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 896 | return RVAL_NONE | RVAL_STR; |
| 897 | } |
| 898 | return 0; |
| 899 | #else |
| 900 | #ifdef SPARC |
| 901 | long i1; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 902 | struct regs regs; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 903 | m_siginfo_t si; |
| 904 | |
| 905 | if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) { |
| 906 | perror("sigreturn: PTRACE_GETREGS "); |
| 907 | return 0; |
| 908 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 909 | if(entering(tcp)) { |
| 910 | tcp->u_arg[0] = 0; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 911 | i1 = regs.r_o1; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 912 | if(umove(tcp, i1, &si) < 0) { |
| 913 | perror("sigreturn: umove "); |
| 914 | return 0; |
| 915 | } |
| 916 | tcp->u_arg[0] = 1; |
| 917 | tcp->u_arg[1] = si.si_mask; |
| 918 | } else { |
| 919 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 920 | long_to_sigset(tcp->u_arg[1], &sigm); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 921 | tcp->u_rval = tcp->u_error = 0; |
| 922 | if(tcp->u_arg[0] == 0) |
| 923 | return 0; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 924 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 925 | return RVAL_NONE | RVAL_STR; |
| 926 | } |
| 927 | return 0; |
Wichert Akkerman | f90da01 | 1999-10-31 21:15:38 +0000 | [diff] [blame] | 928 | #else |
| 929 | #ifdef MIPS |
| 930 | long sp; |
| 931 | struct sigcontext sc; |
| 932 | |
| 933 | if(entering(tcp)) { |
| 934 | tcp->u_arg[0] = 0; |
| 935 | if (upeek(tcp->pid, REG_SP, &sp) < 0) |
| 936 | return 0; |
| 937 | if (umove(tcp, sp, &sc) < 0) |
| 938 | return 0; |
| 939 | tcp->u_arg[0] = 1; |
| 940 | tcp->u_arg[1] = sc.sc_sigset; |
| 941 | } else { |
| 942 | tcp->u_rval = tcp->u_error = 0; |
| 943 | if(tcp->u_arg[0] == 0) |
| 944 | return 0; |
| 945 | tcp->auxstr = sprintsigmask("mask now ", tcp->u_arg[1]); |
| 946 | return RVAL_NONE | RVAL_STR; |
| 947 | } |
| 948 | return 0; |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 949 | #else |
| 950 | #ifdef HPPA |
| 951 | #warning NO sys_sigreturn DECODE FOR HPPA |
| 952 | return 0; |
| 953 | #endif /* HPPA */ |
Wichert Akkerman | f90da01 | 1999-10-31 21:15:38 +0000 | [diff] [blame] | 954 | #endif /* MIPS */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 955 | #endif /* SPARC */ |
| 956 | #endif /* ALPHA */ |
| 957 | #endif /* !M68K */ |
| 958 | #endif /* !POWERPC */ |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 959 | #endif /* !IA64 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 960 | #endif /* !I386 */ |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 961 | #endif /* S390 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 962 | } |
| 963 | |
| 964 | int |
| 965 | sys_siggetmask(tcp) |
| 966 | struct tcb *tcp; |
| 967 | { |
| 968 | if (exiting(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 969 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 970 | long_to_sigset(tcp->u_rval, &sigm); |
| 971 | tcp->auxstr = sprintsigmask("mask ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 972 | } |
| 973 | return RVAL_HEX | RVAL_STR; |
| 974 | } |
| 975 | |
| 976 | int |
| 977 | sys_sigsuspend(tcp) |
| 978 | struct tcb *tcp; |
| 979 | { |
| 980 | if (entering(tcp)) { |
| 981 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 982 | long_to_sigset(tcp->u_arg[2], &sigm); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 983 | #if 0 |
| 984 | /* first two are not really arguments, but print them anyway */ |
| 985 | /* nevermind, they are an anachronism now, too bad... */ |
| 986 | tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 987 | #endif |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 988 | printsigmask(&sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 989 | } |
| 990 | return 0; |
| 991 | } |
| 992 | |
| 993 | #endif /* LINUX */ |
| 994 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 995 | #if defined(SVR4) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 996 | |
| 997 | int |
| 998 | sys_sigsuspend(tcp) |
| 999 | struct tcb *tcp; |
| 1000 | { |
| 1001 | sigset_t sigset; |
| 1002 | |
| 1003 | if (entering(tcp)) { |
| 1004 | if (umove(tcp, tcp->u_arg[0], &sigset) < 0) |
| 1005 | tprintf("[?]"); |
| 1006 | else |
Wichert Akkerman | 4695657 | 1999-11-26 10:12:59 +0000 | [diff] [blame] | 1007 | printsigmask(&sigset, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1008 | } |
| 1009 | return 0; |
| 1010 | } |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1011 | #ifndef FREEBSD |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1012 | static struct xlat ucontext_flags[] = { |
| 1013 | { UC_SIGMASK, "UC_SIGMASK" }, |
| 1014 | { UC_STACK, "UC_STACK" }, |
| 1015 | { UC_CPU, "UC_CPU" }, |
| 1016 | #ifdef UC_FPU |
| 1017 | { UC_FPU, "UC_FPU" }, |
| 1018 | #endif |
| 1019 | #ifdef UC_INTR |
| 1020 | { UC_INTR, "UC_INTR" }, |
| 1021 | #endif |
| 1022 | { 0, NULL }, |
| 1023 | }; |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1024 | #endif /* !FREEBSD */ |
| 1025 | #endif /* SVR4 || FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1026 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1027 | #if defined SVR4 || defined LINUX || defined FREEBSD |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1028 | #if defined LINUX && !defined SS_ONSTACK |
| 1029 | #define SS_ONSTACK 1 |
| 1030 | #define SS_DISABLE 2 |
| 1031 | #if __GLIBC_MINOR__ == 0 |
| 1032 | typedef struct |
| 1033 | { |
| 1034 | __ptr_t ss_sp; |
| 1035 | int ss_flags; |
| 1036 | size_t ss_size; |
| 1037 | } stack_t; |
| 1038 | #endif |
| 1039 | #endif |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1040 | #ifdef FREEBSD |
| 1041 | #define stack_t struct sigaltstack |
| 1042 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1043 | |
| 1044 | static struct xlat sigaltstack_flags[] = { |
| 1045 | { SS_ONSTACK, "SS_ONSTACK" }, |
| 1046 | { SS_DISABLE, "SS_DISABLE" }, |
| 1047 | { 0, NULL }, |
| 1048 | }; |
| 1049 | #endif |
| 1050 | |
| 1051 | #ifdef SVR4 |
| 1052 | static void |
| 1053 | printcontext(tcp, ucp) |
| 1054 | struct tcb *tcp; |
| 1055 | ucontext_t *ucp; |
| 1056 | { |
| 1057 | tprintf("{"); |
| 1058 | if (!abbrev(tcp)) { |
| 1059 | tprintf("uc_flags="); |
| 1060 | if (!printflags(ucontext_flags, ucp->uc_flags)) |
| 1061 | tprintf("0"); |
| 1062 | tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link); |
| 1063 | } |
| 1064 | tprintf("uc_sigmask="); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1065 | printsigmask(ucp->uc_sigmask, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1066 | if (!abbrev(tcp)) { |
| 1067 | tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=", |
| 1068 | (unsigned long) ucp->uc_stack.ss_sp, |
| 1069 | ucp->uc_stack.ss_size); |
| 1070 | if (!printflags(sigaltstack_flags, ucp->uc_stack.ss_flags)) |
| 1071 | tprintf("0"); |
| 1072 | tprintf("}"); |
| 1073 | } |
| 1074 | tprintf(", ...}"); |
| 1075 | } |
| 1076 | |
| 1077 | int |
| 1078 | sys_getcontext(tcp) |
| 1079 | struct tcb *tcp; |
| 1080 | { |
| 1081 | ucontext_t uc; |
| 1082 | |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 1083 | if (exiting(tcp)) { |
| 1084 | if (tcp->u_error) |
| 1085 | tprintf("%#lx", tcp->u_arg[0]); |
| 1086 | else if (!tcp->u_arg[0]) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1087 | tprintf("NULL"); |
| 1088 | else if (umove(tcp, tcp->u_arg[0], &uc) < 0) |
| 1089 | tprintf("{...}"); |
| 1090 | else |
| 1091 | printcontext(tcp, &uc); |
| 1092 | } |
| 1093 | return 0; |
| 1094 | } |
| 1095 | |
| 1096 | int |
| 1097 | sys_setcontext(tcp) |
| 1098 | struct tcb *tcp; |
| 1099 | { |
| 1100 | ucontext_t uc; |
| 1101 | |
| 1102 | if (entering(tcp)) { |
| 1103 | if (!tcp->u_arg[0]) |
| 1104 | tprintf("NULL"); |
| 1105 | else if (umove(tcp, tcp->u_arg[0], &uc) < 0) |
| 1106 | tprintf("{...}"); |
| 1107 | else |
| 1108 | printcontext(tcp, &uc); |
| 1109 | } |
| 1110 | else { |
| 1111 | tcp->u_rval = tcp->u_error = 0; |
| 1112 | if (tcp->u_arg[0] == 0) |
| 1113 | return 0; |
| 1114 | return RVAL_NONE; |
| 1115 | } |
| 1116 | return 0; |
| 1117 | } |
| 1118 | |
| 1119 | #endif /* SVR4 */ |
| 1120 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1121 | #if defined(LINUX) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1122 | |
| 1123 | static int |
| 1124 | print_stack_t(tcp, addr) |
| 1125 | struct tcb *tcp; |
| 1126 | unsigned long addr; |
| 1127 | { |
| 1128 | stack_t ss; |
| 1129 | if (umove(tcp, addr, &ss) < 0) |
| 1130 | return -1; |
| 1131 | tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp); |
| 1132 | if (!printflags(sigaltstack_flags, ss.ss_flags)) |
| 1133 | tprintf("0"); |
| 1134 | tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size); |
| 1135 | return 0; |
| 1136 | } |
| 1137 | |
| 1138 | int |
| 1139 | sys_sigaltstack(tcp) |
| 1140 | struct tcb *tcp; |
| 1141 | { |
| 1142 | if (entering(tcp)) { |
| 1143 | if (tcp->u_arg[0] == 0) |
| 1144 | tprintf("NULL"); |
| 1145 | else if (print_stack_t(tcp, tcp->u_arg[0]) < 0) |
| 1146 | return -1; |
| 1147 | } |
| 1148 | else { |
| 1149 | tprintf(", "); |
| 1150 | if (tcp->u_arg[1] == 0) |
| 1151 | tprintf("NULL"); |
| 1152 | else if (print_stack_t(tcp, tcp->u_arg[1]) < 0) |
| 1153 | return -1; |
| 1154 | } |
| 1155 | return 0; |
| 1156 | } |
| 1157 | #endif |
| 1158 | |
| 1159 | #ifdef HAVE_SIGACTION |
| 1160 | |
| 1161 | int |
| 1162 | sys_sigprocmask(tcp) |
| 1163 | struct tcb *tcp; |
| 1164 | { |
| 1165 | #ifdef ALPHA |
| 1166 | if (entering(tcp)) { |
| 1167 | printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???"); |
| 1168 | tprintf(", "); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1169 | printsigmask(tcp->u_arg[1], 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1170 | } |
| 1171 | else if (!syserror(tcp)) { |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1172 | tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1173 | return RVAL_HEX | RVAL_STR; |
| 1174 | } |
| 1175 | #else /* !ALPHA */ |
| 1176 | sigset_t sigset; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1177 | |
| 1178 | if (entering(tcp)) { |
| 1179 | #ifdef SVR4 |
| 1180 | if (tcp->u_arg[0] == 0) |
| 1181 | tprintf("0"); |
| 1182 | else |
| 1183 | #endif /* SVR4 */ |
| 1184 | printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???"); |
| 1185 | tprintf(", "); |
| 1186 | if (!tcp->u_arg[1]) |
| 1187 | tprintf("NULL, "); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1188 | else if (copy_sigset(tcp, tcp->u_arg[1], &sigset) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1189 | tprintf("%#lx, ", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1190 | else { |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1191 | printsigmask(&sigset, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1192 | tprintf(", "); |
| 1193 | } |
| 1194 | } |
| 1195 | else { |
| 1196 | if (!tcp->u_arg[2]) |
| 1197 | tprintf("NULL"); |
| 1198 | else if (syserror(tcp)) |
| 1199 | tprintf("%#lx", tcp->u_arg[2]); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1200 | else if (copy_sigset(tcp, tcp->u_arg[2], &sigset) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1201 | tprintf("[?]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1202 | else |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1203 | printsigmask(&sigset, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1204 | } |
| 1205 | #endif /* !ALPHA */ |
| 1206 | return 0; |
| 1207 | } |
| 1208 | |
| 1209 | #endif /* HAVE_SIGACTION */ |
| 1210 | |
| 1211 | int |
| 1212 | sys_kill(tcp) |
| 1213 | struct tcb *tcp; |
| 1214 | { |
| 1215 | if (entering(tcp)) { |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 1216 | tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1])); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1217 | } |
| 1218 | return 0; |
| 1219 | } |
| 1220 | |
| 1221 | int |
| 1222 | sys_killpg(tcp) |
| 1223 | struct tcb *tcp; |
| 1224 | { |
| 1225 | return sys_kill(tcp); |
| 1226 | } |
| 1227 | |
| 1228 | int |
| 1229 | sys_sigpending(tcp) |
| 1230 | struct tcb *tcp; |
| 1231 | { |
| 1232 | sigset_t sigset; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1233 | |
| 1234 | if (exiting(tcp)) { |
| 1235 | if (syserror(tcp)) |
| 1236 | tprintf("%#lx", tcp->u_arg[0]); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1237 | else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1238 | tprintf("[?]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1239 | else |
Wichert Akkerman | 4695657 | 1999-11-26 10:12:59 +0000 | [diff] [blame] | 1240 | printsigmask(&sigset, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1241 | } |
| 1242 | return 0; |
| 1243 | } |
| 1244 | |
| 1245 | #ifdef LINUX |
| 1246 | |
| 1247 | int |
| 1248 | sys_rt_sigprocmask(tcp) |
| 1249 | struct tcb *tcp; |
| 1250 | { |
| 1251 | sigset_t sigset; |
| 1252 | |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1253 | /* Note: arg[3] is the length of the sigset. */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1254 | if (entering(tcp)) { |
| 1255 | printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???"); |
| 1256 | tprintf(", "); |
| 1257 | if (!tcp->u_arg[1]) |
| 1258 | tprintf("NULL, "); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1259 | else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1260 | tprintf("%#lx, ", tcp->u_arg[1]); |
| 1261 | else { |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1262 | printsigmask(&sigset, 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1263 | tprintf(", "); |
| 1264 | } |
| 1265 | } |
| 1266 | else { |
| 1267 | if (!tcp->u_arg[2]) |
| 1268 | |
| 1269 | tprintf("NULL"); |
| 1270 | else if (syserror(tcp)) |
| 1271 | tprintf("%#lx", tcp->u_arg[2]); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1272 | else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1273 | tprintf("[?]"); |
| 1274 | else |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1275 | printsigmask(&sigset, 1); |
Nate Sammons | dab325a | 1999-03-29 23:33:35 +0000 | [diff] [blame] | 1276 | tprintf(", %lu", tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1277 | } |
| 1278 | return 0; |
| 1279 | } |
| 1280 | |
| 1281 | #if __GLIBC_MINOR__ < 1 |
| 1282 | /* Type for data associated with a signal. */ |
| 1283 | typedef union sigval |
| 1284 | { |
| 1285 | int sival_int; |
| 1286 | void *sival_ptr; |
| 1287 | } sigval_t; |
| 1288 | |
| 1289 | # define __SI_MAX_SIZE 128 |
| 1290 | # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3) |
| 1291 | |
| 1292 | typedef struct siginfo |
| 1293 | { |
| 1294 | int si_signo; /* Signal number. */ |
| 1295 | int si_errno; /* If non-zero, an errno value associated with |
| 1296 | this signal, as defined in <errno.h>. */ |
| 1297 | int si_code; /* Signal code. */ |
| 1298 | |
| 1299 | union |
| 1300 | { |
| 1301 | int _pad[__SI_PAD_SIZE]; |
| 1302 | |
| 1303 | /* kill(). */ |
| 1304 | struct |
| 1305 | { |
| 1306 | __pid_t si_pid; /* Sending process ID. */ |
| 1307 | __uid_t si_uid; /* Real user ID of sending process. */ |
| 1308 | } _kill; |
| 1309 | |
| 1310 | /* POSIX.1b timers. */ |
| 1311 | struct |
| 1312 | { |
| 1313 | unsigned int _timer1; |
| 1314 | unsigned int _timer2; |
| 1315 | } _timer; |
| 1316 | |
| 1317 | /* POSIX.1b signals. */ |
| 1318 | struct |
| 1319 | { |
| 1320 | __pid_t si_pid; /* Sending process ID. */ |
| 1321 | __uid_t si_uid; /* Real user ID of sending process. */ |
| 1322 | sigval_t si_sigval; /* Signal value. */ |
| 1323 | } _rt; |
| 1324 | |
| 1325 | /* SIGCHLD. */ |
| 1326 | struct |
| 1327 | { |
| 1328 | __pid_t si_pid; /* Which child. */ |
| 1329 | int si_status; /* Exit value or signal. */ |
| 1330 | __clock_t si_utime; |
| 1331 | __clock_t si_stime; |
| 1332 | } _sigchld; |
| 1333 | |
| 1334 | /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */ |
| 1335 | struct |
| 1336 | { |
| 1337 | void *si_addr; /* Faulting insn/memory ref. */ |
| 1338 | } _sigfault; |
| 1339 | |
| 1340 | /* SIGPOLL. */ |
| 1341 | struct |
| 1342 | { |
| 1343 | int si_band; /* Band event for SIGPOLL. */ |
| 1344 | int si_fd; |
| 1345 | } _sigpoll; |
| 1346 | } _sifields; |
| 1347 | } siginfo_t; |
| 1348 | #endif |
| 1349 | |
| 1350 | /* Structure describing the action to be taken when a signal arrives. */ |
| 1351 | struct new_sigaction |
| 1352 | { |
| 1353 | union |
| 1354 | { |
| 1355 | __sighandler_t __sa_handler; |
| 1356 | void (*__sa_sigaction) (int, siginfo_t *, void *); |
| 1357 | } |
| 1358 | __sigaction_handler; |
| 1359 | unsigned long sa_flags; |
| 1360 | void (*sa_restorer) (void); |
| 1361 | unsigned long int sa_mask[2]; |
| 1362 | }; |
| 1363 | |
| 1364 | |
| 1365 | int |
| 1366 | sys_rt_sigaction(tcp) |
| 1367 | struct tcb *tcp; |
| 1368 | { |
| 1369 | struct new_sigaction sa; |
| 1370 | sigset_t sigset; |
| 1371 | long addr; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1372 | |
| 1373 | if (entering(tcp)) { |
| 1374 | printsignal(tcp->u_arg[0]); |
| 1375 | tprintf(", "); |
| 1376 | addr = tcp->u_arg[1]; |
| 1377 | } else |
| 1378 | addr = tcp->u_arg[2]; |
| 1379 | if (addr == 0) |
| 1380 | tprintf("NULL"); |
| 1381 | else if (!verbose(tcp)) |
| 1382 | tprintf("%#lx", addr); |
| 1383 | else if (umove(tcp, addr, &sa) < 0) |
| 1384 | tprintf("{...}"); |
| 1385 | else { |
| 1386 | switch ((long) sa.__sigaction_handler.__sa_handler) { |
| 1387 | case (long) SIG_ERR: |
| 1388 | tprintf("{SIG_ERR}"); |
| 1389 | break; |
| 1390 | case (long) SIG_DFL: |
| 1391 | tprintf("{SIG_DFL}"); |
| 1392 | break; |
| 1393 | case (long) SIG_IGN: |
| 1394 | tprintf("{SIG_IGN}"); |
| 1395 | break; |
| 1396 | default: |
| 1397 | tprintf("{%#lx, ", |
| 1398 | (long) sa.__sigaction_handler.__sa_handler); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1399 | sigemptyset(&sigset); |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 1400 | #ifdef LINUXSPARC |
| 1401 | if (tcp->u_arg[4] <= sizeof(sigset)) |
| 1402 | memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]); |
| 1403 | #else |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1404 | if (tcp->u_arg[3] <= sizeof(sigset)) |
| 1405 | memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]); |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 1406 | #endif |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1407 | else |
| 1408 | memcpy(&sigset, &sa.sa_mask, sizeof(sigset)); |
| 1409 | printsigmask(&sigset, 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1410 | tprintf(", "); |
| 1411 | if (!printflags(sigact_flags, sa.sa_flags)) |
| 1412 | tprintf("0"); |
| 1413 | tprintf("}"); |
| 1414 | } |
| 1415 | } |
| 1416 | if (entering(tcp)) |
| 1417 | tprintf(", "); |
| 1418 | else |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 1419 | #ifdef LINUXSPARC |
| 1420 | tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]); |
| 1421 | #elif defined(ALPHA) |
| 1422 | tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]); |
| 1423 | #else |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1424 | tprintf(", %lu", addr = tcp->u_arg[3]); |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 1425 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1426 | return 0; |
| 1427 | } |
| 1428 | |
| 1429 | int |
| 1430 | sys_rt_sigpending(tcp) |
| 1431 | struct tcb *tcp; |
| 1432 | { |
| 1433 | sigset_t sigset; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1434 | |
| 1435 | if (exiting(tcp)) { |
| 1436 | if (syserror(tcp)) |
| 1437 | tprintf("%#lx", tcp->u_arg[0]); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1438 | else if (copy_sigset_len(tcp, tcp->u_arg[0], |
| 1439 | &sigset, tcp->u_arg[1]) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1440 | tprintf("[?]"); |
| 1441 | else |
Wichert Akkerman | 4695657 | 1999-11-26 10:12:59 +0000 | [diff] [blame] | 1442 | printsigmask(&sigset, 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1443 | } |
| 1444 | return 0; |
| 1445 | } |
| 1446 | int |
| 1447 | sys_rt_sigsuspend(tcp) |
| 1448 | struct tcb *tcp; |
| 1449 | { |
| 1450 | if (entering(tcp)) { |
| 1451 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1452 | if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0) |
| 1453 | tprintf("[?]"); |
| 1454 | else |
| 1455 | printsigmask(&sigm, 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1456 | } |
| 1457 | return 0; |
| 1458 | } |
| 1459 | #ifndef ILL_ILLOPC |
| 1460 | #define ILL_ILLOPC 1 /* illegal opcode */ |
| 1461 | #define ILL_ILLOPN 2 /* illegal operand */ |
| 1462 | #define ILL_ILLADR 3 /* illegal addressing mode */ |
| 1463 | #define ILL_ILLTRP 4 /* illegal trap */ |
| 1464 | #define ILL_PRVOPC 5 /* privileged opcode */ |
| 1465 | #define ILL_PRVREG 6 /* privileged register */ |
| 1466 | #define ILL_COPROC 7 /* coprocessor error */ |
| 1467 | #define ILL_BADSTK 8 /* internal stack error */ |
| 1468 | #define FPE_INTDIV 1 /* integer divide by zero */ |
| 1469 | #define FPE_INTOVF 2 /* integer overflow */ |
| 1470 | #define FPE_FLTDIV 3 /* floating point divide by zero */ |
| 1471 | #define FPE_FLTOVF 4 /* floating point overflow */ |
| 1472 | #define FPE_FLTUND 5 /* floating point underflow */ |
| 1473 | #define FPE_FLTRES 6 /* floating point inexact result */ |
| 1474 | #define FPE_FLTINV 7 /* floating point invalid operation */ |
| 1475 | #define FPE_FLTSUB 8 /* subscript out of range */ |
| 1476 | #define SEGV_MAPERR 1 /* address not mapped to object */ |
| 1477 | #define SEGV_ACCERR 2 /* invalid permissions for mapped object */ |
| 1478 | #define BUS_ADRALN 1 /* invalid address alignment */ |
| 1479 | #define BUS_ADRERR 2 /* non-existant physical address */ |
| 1480 | #define BUS_OBJERR 3 /* object specific hardware error */ |
| 1481 | #define TRAP_BRKPT 1 /* process breakpoint */ |
| 1482 | #define TRAP_TRACE 2 /* process trace trap */ |
| 1483 | #define CLD_EXITED 1 /* child has exited */ |
| 1484 | #define CLD_KILLED 2 /* child was killed */ |
| 1485 | #define CLD_DUMPED 3 /* child terminated abnormally */ |
| 1486 | #define CLD_TRAPPED 4 /* traced child has trapped */ |
| 1487 | #define CLD_STOPPED 5 /* child has stopped */ |
| 1488 | #define CLD_CONTINUED 6 /* stopped child has continued */ |
| 1489 | #define POLL_IN 1 /* data input available */ |
| 1490 | #define POLL_OUT 2 /* output buffers available */ |
| 1491 | #define POLL_MSG 3 /* input message available */ |
| 1492 | #define POLL_ERR 4 /* i/o error */ |
| 1493 | #define POLL_PRI 5 /* high priority input available */ |
| 1494 | #define POLL_HUP 6 /* device disconnected */ |
| 1495 | #define SI_USER 0 /* sent by kill, sigsend, raise */ |
| 1496 | #define SI_QUEUE -1 /* sent by sigqueue */ |
| 1497 | #define SI_TIMER -2 /* sent by timer expiration */ |
| 1498 | #define SI_MESGQ -3 /* sent by real time mesq state change */ |
| 1499 | #define SI_ASYNCIO -4 /* sent by AIO completion */ |
| 1500 | #else |
| 1501 | #undef si_pid |
| 1502 | #undef si_uid |
| 1503 | #undef si_status |
| 1504 | #undef si_utime |
| 1505 | #undef si_stime |
| 1506 | #undef si_value |
| 1507 | #undef si_int |
| 1508 | #undef si_ptr |
| 1509 | #undef si_addr |
| 1510 | #undef si_band |
| 1511 | #undef si_fd |
| 1512 | #endif |
| 1513 | |
| 1514 | static struct xlat sigill_flags[] = { |
| 1515 | {ILL_ILLOPC, "ILL_ILLOPC"}, |
| 1516 | {ILL_ILLOPN, "ILL_ILLOPN"}, |
| 1517 | {ILL_ILLADR, "ILL_ILLADR"}, |
| 1518 | {ILL_ILLTRP, "ILL_ILLTRP"}, |
| 1519 | {ILL_PRVOPC, "ILL_PRVOPC"}, |
| 1520 | {ILL_PRVREG, "ILL_PRVREG"}, |
| 1521 | {ILL_COPROC, "ILL_COPROC"}, |
| 1522 | {ILL_BADSTK, "ILL_BADSTK"}, |
| 1523 | {0, NULL} |
| 1524 | }; |
| 1525 | |
| 1526 | static struct xlat sigfpe_flags[] = { |
| 1527 | {FPE_INTDIV, "FPE_INTDIV"}, |
| 1528 | {FPE_INTOVF, "FPE_INTOVF"}, |
| 1529 | {FPE_FLTDIV, "FPE_FLTDIV"}, |
| 1530 | {FPE_FLTOVF, "FPE_FLTOVF"}, |
| 1531 | {FPE_FLTUND, "FPE_FLTUND"}, |
| 1532 | {FPE_FLTRES, "FPE_FLTRES"}, |
| 1533 | {FPE_FLTINV, "FPE_FLTINV"}, |
| 1534 | {FPE_FLTSUB, "FPE_FLTSUB"}, |
| 1535 | {0, NULL} |
| 1536 | }; |
| 1537 | |
| 1538 | static struct xlat sigsegv_flags[] = { |
| 1539 | {SEGV_MAPERR, "SEGV_MAPERR"}, |
| 1540 | {SEGV_ACCERR, "SEGV_ACCERR"}, |
| 1541 | {0, NULL} |
| 1542 | }; |
| 1543 | |
| 1544 | static struct xlat sigbus_flags[] = { |
| 1545 | {BUS_ADRALN, "BUS_ADRALN"}, |
| 1546 | {BUS_ADRERR, "BUS_ADRERR"}, |
| 1547 | {BUS_OBJERR, "BUS_OBJERR"}, |
| 1548 | {0, NULL} |
| 1549 | }; |
| 1550 | |
| 1551 | static struct xlat sigtrap_flags[] = { |
| 1552 | {TRAP_BRKPT, "TRAP_BRKPT"}, |
| 1553 | {TRAP_TRACE, "TRAP_TRACE"}, |
| 1554 | {0, NULL} |
| 1555 | }; |
| 1556 | |
| 1557 | static struct xlat sigchld_flags[] = { |
| 1558 | {CLD_EXITED, "CLD_EXITED"}, |
| 1559 | {CLD_KILLED, "CLD_KILLED"}, |
| 1560 | {CLD_DUMPED, "CLD_DUMPED"}, |
| 1561 | {CLD_TRAPPED, "CLD_TRAPPED"}, |
| 1562 | {CLD_STOPPED, "CLD_STOPPED"}, |
| 1563 | {CLD_CONTINUED, "CLD_CONTINUED"}, |
| 1564 | {0, NULL} |
| 1565 | }; |
| 1566 | |
| 1567 | static struct xlat sigpoll_flags[] = { |
| 1568 | {POLL_IN, "POLL_IN"}, |
| 1569 | {POLL_OUT, "POLL_OUT"}, |
| 1570 | {POLL_MSG, "POLL_MSG"}, |
| 1571 | {POLL_ERR, "POLL_ERR"}, |
| 1572 | {POLL_PRI, "POLL_PRI"}, |
| 1573 | {POLL_HUP, "POLL_HUP"}, |
| 1574 | {0, NULL} |
| 1575 | }; |
| 1576 | |
| 1577 | static struct xlat siginfo_flags[] = { |
| 1578 | {SI_USER, "SI_USER"}, |
| 1579 | {SI_QUEUE, "SI_QUEUE"}, |
| 1580 | {SI_TIMER, "SI_TIMER"}, |
| 1581 | {SI_MESGQ, "SI_MESGQ"}, |
| 1582 | {SI_ASYNCIO, "SI_ASYNCIO"}, |
| 1583 | {0, NULL} |
| 1584 | }; |
| 1585 | |
| 1586 | static void |
| 1587 | printsiginfo(tcp, si) |
| 1588 | struct tcb *tcp; |
| 1589 | siginfo_t *si; |
| 1590 | { |
| 1591 | tprintf("{si_signo="); |
| 1592 | printsignal(si->si_signo); |
| 1593 | tprintf(", si_errno=%d, si_code=", si->si_errno); |
| 1594 | switch(si->si_signo) |
| 1595 | { |
| 1596 | case SIGILL: |
| 1597 | if (!printflags(sigill_flags, si->si_code)) |
| 1598 | tprintf("%d /* ILL_??? */", si->si_code); |
| 1599 | tprintf(", si_addr=%lx", |
| 1600 | (unsigned long) si->_sifields._sigfault.si_addr); |
| 1601 | break; |
| 1602 | case SIGFPE: |
| 1603 | if (!printflags(sigfpe_flags, si->si_code)) |
| 1604 | tprintf("%d /* FPE_??? */", si->si_code); |
| 1605 | tprintf(", si_addr=%lx", |
| 1606 | (unsigned long) si->_sifields._sigfault.si_addr); |
| 1607 | break; |
| 1608 | case SIGSEGV: |
| 1609 | if (!printflags(sigsegv_flags, si->si_code)) |
| 1610 | tprintf("%d /* SEGV_??? */", si->si_code); |
| 1611 | tprintf(", si_addr=%lx", |
| 1612 | (unsigned long) si->_sifields._sigfault.si_addr); |
| 1613 | break; |
| 1614 | case SIGBUS: |
| 1615 | if (!printflags(sigbus_flags, si->si_code)) |
| 1616 | tprintf("%d /* BUS_??? */", si->si_code); |
| 1617 | tprintf(", si_addr=%lx", |
| 1618 | (unsigned long) si->_sifields._sigfault.si_addr); |
| 1619 | break; |
| 1620 | case SIGTRAP: |
| 1621 | if (!printflags(sigtrap_flags, si->si_code)) |
| 1622 | tprintf("%d /* TRAP_??? */", si->si_code); |
| 1623 | break; |
| 1624 | case SIGCHLD: |
| 1625 | if (!printflags(sigchld_flags, si->si_code)) |
| 1626 | tprintf("%d /* CLD_??? */", si->si_code); |
| 1627 | if (!verbose(tcp)) |
| 1628 | tprintf(", ..."); |
| 1629 | else |
| 1630 | tprintf(", si_pid=%d, si_uid=%d, si_status=%d, si_utime=%lu, si_stime=%lu", |
| 1631 | si->_sifields._kill.si_pid, |
| 1632 | si->_sifields._kill.si_uid, |
| 1633 | si->_sifields._sigchld.si_status, |
| 1634 | si->_sifields._sigchld.si_utime, |
| 1635 | si->_sifields._sigchld.si_stime); |
| 1636 | break; |
| 1637 | case SIGPOLL: |
| 1638 | if (!printflags(sigpoll_flags, si->si_code)) |
| 1639 | tprintf("%d /* POLL_??? */", si->si_code); |
| 1640 | if (si->si_code == POLL_IN |
| 1641 | || si->si_code == POLL_OUT |
| 1642 | || si->si_code == POLL_MSG) |
| 1643 | tprintf(", si_bind=%lu, si_fd=%d", |
| 1644 | (unsigned long) si->_sifields._sigpoll.si_band, |
| 1645 | si->_sifields._sigpoll.si_fd); |
| 1646 | break; |
| 1647 | default: |
| 1648 | if (!printflags(siginfo_flags, si->si_code)) |
| 1649 | tprintf("%d /* SI_??? */", si->si_code); |
| 1650 | tprintf(", si_pid=%lu, si_uid=%lu, si_value={", |
| 1651 | (unsigned long) si->_sifields._rt.si_pid, |
| 1652 | (unsigned long) si->_sifields._rt.si_uid); |
| 1653 | if (!verbose(tcp)) |
| 1654 | tprintf("..."); |
| 1655 | else { |
| 1656 | tprintf("sival_int=%u, sival_ptr=%#lx", |
| 1657 | si->_sifields._rt.si_sigval.sival_int, |
| 1658 | (unsigned long) si->_sifields._rt.si_sigval.sival_ptr); |
| 1659 | } |
| 1660 | tprintf("}"); |
| 1661 | break; |
| 1662 | } |
| 1663 | tprintf("}"); |
| 1664 | } |
| 1665 | |
| 1666 | int |
| 1667 | sys_rt_sigqueueinfo(tcp) |
| 1668 | struct tcb *tcp; |
| 1669 | { |
| 1670 | if (entering(tcp)) { |
| 1671 | siginfo_t si; |
| 1672 | tprintf("%lu, ", tcp->u_arg[0]); |
| 1673 | printsignal(tcp->u_arg[1]); |
| 1674 | tprintf(", "); |
| 1675 | if (umove(tcp, tcp->u_arg[2], &si) < 0) |
| 1676 | tprintf("%#lx", tcp->u_arg[2]); |
| 1677 | else |
| 1678 | printsiginfo(&si); |
| 1679 | } |
| 1680 | return 0; |
| 1681 | } |
| 1682 | |
| 1683 | int sys_rt_sigtimedwait(tcp) |
| 1684 | struct tcb *tcp; |
| 1685 | { |
| 1686 | if (entering(tcp)) { |
| 1687 | sigset_t sigset; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1688 | |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1689 | if (copy_sigset_len(tcp, tcp->u_arg[0], |
| 1690 | &sigset, tcp->u_arg[3]) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1691 | tprintf("[?]"); |
| 1692 | else |
Wichert Akkerman | 4695657 | 1999-11-26 10:12:59 +0000 | [diff] [blame] | 1693 | printsigmask(&sigset, 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1694 | tprintf(", "); |
| 1695 | } |
| 1696 | else { |
| 1697 | if (syserror(tcp)) |
| 1698 | tprintf("%#lx", tcp->u_arg[0]); |
| 1699 | else { |
| 1700 | siginfo_t si; |
| 1701 | if (umove(tcp, tcp->u_arg[1], &si) < 0) |
| 1702 | tprintf("%#lx", tcp->u_arg[1]); |
| 1703 | else |
| 1704 | printsiginfo(&si); |
| 1705 | /* XXX For now */ |
| 1706 | tprintf(", %#lx", tcp->u_arg[2]); |
| 1707 | tprintf(", %d", (int) tcp->u_arg[3]); |
| 1708 | } |
| 1709 | } |
| 1710 | return 0; |
| 1711 | }; |
| 1712 | |
| 1713 | #endif /* LINUX */ |
| 1714 | |