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 |
Roland McGrath | a39c5a1 | 2002-12-17 05:10:37 +0000 | [diff] [blame^] | 76 | # undef fpu |
Wichert Akkerman | 00a82ee | 2001-03-28 20:29:17 +0000 | [diff] [blame] | 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; |
Michal Ludvig | 0e03550 | 2002-09-23 15:41:01 +0000 | [diff] [blame] | 86 | #elif !defined(IA64) && !defined(X86_64) |
Wichert Akkerman | 00a82ee | 2001-03-28 20:29:17 +0000 | [diff] [blame] | 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 | |
Roland McGrath | 2638cb4 | 2002-12-15 23:58:41 +0000 | [diff] [blame] | 177 | #if defined LINUX && defined I386 |
| 178 | /* The libc headers do not define this constant since it should only be |
| 179 | used by the implementation. So wwe define it here. */ |
| 180 | # ifndef SA_RESTORER |
| 181 | # define SA_RESTORER 0x04000000 |
| 182 | # endif |
| 183 | #endif |
| 184 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 185 | static struct xlat sigact_flags[] = { |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 186 | #ifdef SA_RESTORER |
| 187 | { SA_RESTORER, "SA_RESTORER" }, |
| 188 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 189 | #ifdef SA_STACK |
| 190 | { SA_STACK, "SA_STACK" }, |
| 191 | #endif |
| 192 | #ifdef SA_RESTART |
| 193 | { SA_RESTART, "SA_RESTART" }, |
| 194 | #endif |
| 195 | #ifdef SA_INTERRUPT |
| 196 | { SA_INTERRUPT, "SA_INTERRUPT" }, |
| 197 | #endif |
| 198 | #ifdef SA_NOMASK |
| 199 | { SA_NOMASK, "SA_NOMASK" }, |
| 200 | #endif |
| 201 | #ifdef SA_ONESHOT |
| 202 | { SA_ONESHOT, "SA_ONESHOT" }, |
| 203 | #endif |
| 204 | #ifdef SA_SIGINFO |
| 205 | { SA_SIGINFO, "SA_SIGINFO" }, |
| 206 | #endif |
| 207 | #ifdef SA_RESETHAND |
| 208 | { SA_RESETHAND, "SA_RESETHAND" }, |
| 209 | #endif |
| 210 | #ifdef SA_ONSTACK |
| 211 | { SA_ONSTACK, "SA_ONSTACK" }, |
| 212 | #endif |
| 213 | #ifdef SA_NODEFER |
| 214 | { SA_NODEFER, "SA_NODEFER" }, |
| 215 | #endif |
| 216 | #ifdef SA_NOCLDSTOP |
| 217 | { SA_NOCLDSTOP, "SA_NOCLDSTOP" }, |
| 218 | #endif |
| 219 | #ifdef SA_NOCLDWAIT |
| 220 | { SA_NOCLDWAIT, "SA_NOCLDWAIT" }, |
| 221 | #endif |
| 222 | #ifdef _SA_BSDCALL |
| 223 | { _SA_BSDCALL, "_SA_BSDCALL" }, |
| 224 | #endif |
| 225 | { 0, NULL }, |
| 226 | }; |
| 227 | |
| 228 | static struct xlat sigprocmaskcmds[] = { |
| 229 | { SIG_BLOCK, "SIG_BLOCK" }, |
| 230 | { SIG_UNBLOCK, "SIG_UNBLOCK" }, |
| 231 | { SIG_SETMASK, "SIG_SETMASK" }, |
| 232 | #ifdef SIG_SETMASK32 |
| 233 | { SIG_SETMASK32,"SIG_SETMASK32" }, |
| 234 | #endif |
| 235 | { 0, NULL }, |
| 236 | }; |
| 237 | |
| 238 | #endif /* HAVE_SIGACTION */ |
| 239 | |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 240 | /* Anonymous realtime signals. */ |
| 241 | /* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a |
| 242 | constant. This is what we want. Otherwise, just use SIGRTMIN. */ |
| 243 | #ifdef SIGRTMIN |
| 244 | #ifndef __SIGRTMIN |
| 245 | #define __SIGRTMIN SIGRTMIN |
| 246 | #define __SIGRTMAX SIGRTMAX /* likewise */ |
| 247 | #endif |
| 248 | #endif |
| 249 | |
| 250 | char * |
| 251 | signame(sig) |
| 252 | int sig; |
| 253 | { |
| 254 | static char buf[30]; |
| 255 | if (sig < nsignals) { |
| 256 | return signalent[sig]; |
| 257 | #ifdef SIGRTMIN |
Nate Sammons | 3080aa4 | 1999-03-30 00:16:41 +0000 | [diff] [blame] | 258 | } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 259 | sprintf(buf, "SIGRT_%ld", (long)(sig - __SIGRTMIN)); |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 260 | return buf; |
| 261 | #endif /* SIGRTMIN */ |
| 262 | } else { |
| 263 | sprintf(buf, "%d", sig); |
| 264 | return buf; |
| 265 | } |
| 266 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 267 | |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 268 | #ifndef UNIXWARE |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 269 | static void |
| 270 | long_to_sigset(l, s) |
| 271 | long l; |
| 272 | sigset_t *s; |
| 273 | { |
| 274 | sigemptyset(s); |
| 275 | *(long *)s = l; |
| 276 | } |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 277 | #endif |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 278 | |
| 279 | static int |
| 280 | copy_sigset_len(tcp, addr, s, len) |
| 281 | struct tcb *tcp; |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 282 | long addr; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 283 | sigset_t *s; |
| 284 | int len; |
| 285 | { |
| 286 | if (len > sizeof(*s)) |
| 287 | len = sizeof(*s); |
| 288 | sigemptyset(s); |
| 289 | if (umoven(tcp, addr, len, (char *)s) < 0) |
| 290 | return -1; |
| 291 | return 0; |
| 292 | } |
| 293 | |
| 294 | #ifdef LINUX |
| 295 | /* Original sigset is unsigned long */ |
| 296 | #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(long)) |
| 297 | #else |
| 298 | #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(sigset_t)) |
| 299 | #endif |
| 300 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 301 | static char * |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 302 | sprintsigmask(s, mask, rt) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 303 | char *s; |
| 304 | sigset_t *mask; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 305 | int rt; /* set might include realtime sigs */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 306 | { |
| 307 | int i, nsigs; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 308 | int maxsigs; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 309 | char *format; |
Roland McGrath | a39c5a1 | 2002-12-17 05:10:37 +0000 | [diff] [blame^] | 310 | static char outstr[8 * sizeof(sigset_t) * 8]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 311 | |
| 312 | strcpy(outstr, s); |
| 313 | s = outstr + strlen(outstr); |
| 314 | nsigs = 0; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 315 | maxsigs = nsignals; |
| 316 | #ifdef __SIGRTMAX |
| 317 | if (rt) |
| 318 | maxsigs = __SIGRTMAX; /* instead */ |
| 319 | #endif |
| 320 | for (i = 1; i < maxsigs; i++) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 321 | if (sigismember(mask, i) == 1) |
| 322 | nsigs++; |
| 323 | } |
| 324 | if (nsigs >= nsignals * 2 / 3) { |
| 325 | *s++ = '~'; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 326 | for (i = 1; i < maxsigs; i++) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 327 | switch (sigismember(mask, i)) { |
| 328 | case 1: |
| 329 | sigdelset(mask, i); |
| 330 | break; |
| 331 | case 0: |
| 332 | sigaddset(mask, i); |
| 333 | break; |
| 334 | } |
| 335 | } |
| 336 | } |
| 337 | format = "%s"; |
| 338 | *s++ = '['; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 339 | for (i = 1; i < maxsigs; i++) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 340 | if (sigismember(mask, i) == 1) { |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 341 | /* real-time signals on solaris don't have |
| 342 | * signalent entries |
| 343 | */ |
| 344 | if (i < nsignals) { |
| 345 | sprintf(s, format, signalent[i] + 3); |
| 346 | } |
| 347 | else { |
| 348 | char tsig[32]; |
| 349 | sprintf(tsig, "%u", i); |
| 350 | sprintf(s, format, tsig); |
| 351 | } |
| 352 | s += strlen(s); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 353 | format = " %s"; |
| 354 | } |
| 355 | } |
| 356 | *s++ = ']'; |
| 357 | *s = '\0'; |
| 358 | return outstr; |
| 359 | } |
| 360 | |
| 361 | static void |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 362 | printsigmask(mask, rt) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 363 | sigset_t *mask; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 364 | int rt; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 365 | { |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 366 | tprintf("%s", sprintsigmask("", mask, rt)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | void |
| 370 | printsignal(nr) |
| 371 | int nr; |
| 372 | { |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 373 | tprintf(signame(nr)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 374 | } |
| 375 | |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 376 | #ifdef LINUX |
| 377 | |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 378 | #ifndef ILL_ILLOPC |
| 379 | #define ILL_ILLOPC 1 /* illegal opcode */ |
| 380 | #define ILL_ILLOPN 2 /* illegal operand */ |
| 381 | #define ILL_ILLADR 3 /* illegal addressing mode */ |
| 382 | #define ILL_ILLTRP 4 /* illegal trap */ |
| 383 | #define ILL_PRVOPC 5 /* privileged opcode */ |
| 384 | #define ILL_PRVREG 6 /* privileged register */ |
| 385 | #define ILL_COPROC 7 /* coprocessor error */ |
| 386 | #define ILL_BADSTK 8 /* internal stack error */ |
| 387 | #define FPE_INTDIV 1 /* integer divide by zero */ |
| 388 | #define FPE_INTOVF 2 /* integer overflow */ |
| 389 | #define FPE_FLTDIV 3 /* floating point divide by zero */ |
| 390 | #define FPE_FLTOVF 4 /* floating point overflow */ |
| 391 | #define FPE_FLTUND 5 /* floating point underflow */ |
| 392 | #define FPE_FLTRES 6 /* floating point inexact result */ |
| 393 | #define FPE_FLTINV 7 /* floating point invalid operation */ |
| 394 | #define FPE_FLTSUB 8 /* subscript out of range */ |
| 395 | #define SEGV_MAPERR 1 /* address not mapped to object */ |
| 396 | #define SEGV_ACCERR 2 /* invalid permissions for mapped object */ |
| 397 | #define BUS_ADRALN 1 /* invalid address alignment */ |
| 398 | #define BUS_ADRERR 2 /* non-existant physical address */ |
| 399 | #define BUS_OBJERR 3 /* object specific hardware error */ |
| 400 | #define TRAP_BRKPT 1 /* process breakpoint */ |
| 401 | #define TRAP_TRACE 2 /* process trace trap */ |
| 402 | #define CLD_EXITED 1 /* child has exited */ |
| 403 | #define CLD_KILLED 2 /* child was killed */ |
| 404 | #define CLD_DUMPED 3 /* child terminated abnormally */ |
| 405 | #define CLD_TRAPPED 4 /* traced child has trapped */ |
| 406 | #define CLD_STOPPED 5 /* child has stopped */ |
| 407 | #define CLD_CONTINUED 6 /* stopped child has continued */ |
| 408 | #define POLL_IN 1 /* data input available */ |
| 409 | #define POLL_OUT 2 /* output buffers available */ |
| 410 | #define POLL_MSG 3 /* input message available */ |
| 411 | #define POLL_ERR 4 /* i/o error */ |
| 412 | #define POLL_PRI 5 /* high priority input available */ |
| 413 | #define POLL_HUP 6 /* device disconnected */ |
| 414 | #define SI_USER 0 /* sent by kill, sigsend, raise */ |
| 415 | #define SI_QUEUE -1 /* sent by sigqueue */ |
| 416 | #define SI_TIMER -2 /* sent by timer expiration */ |
| 417 | #define SI_MESGQ -3 /* sent by real time mesq state change */ |
| 418 | #define SI_ASYNCIO -4 /* sent by AIO completion */ |
| 419 | #endif |
| 420 | |
| 421 | #if __GLIBC_MINOR__ < 1 |
| 422 | /* Type for data associated with a signal. */ |
| 423 | typedef union sigval |
| 424 | { |
| 425 | int sival_int; |
| 426 | void *sival_ptr; |
| 427 | } sigval_t; |
| 428 | |
| 429 | # define __SI_MAX_SIZE 128 |
| 430 | # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3) |
| 431 | |
| 432 | typedef struct siginfo |
| 433 | { |
| 434 | int si_signo; /* Signal number. */ |
| 435 | int si_errno; /* If non-zero, an errno value associated with |
| 436 | this signal, as defined in <errno.h>. */ |
| 437 | int si_code; /* Signal code. */ |
| 438 | |
| 439 | union |
| 440 | { |
| 441 | int _pad[__SI_PAD_SIZE]; |
| 442 | |
| 443 | /* kill(). */ |
| 444 | struct |
| 445 | { |
| 446 | __pid_t si_pid; /* Sending process ID. */ |
| 447 | __uid_t si_uid; /* Real user ID of sending process. */ |
| 448 | } _kill; |
| 449 | |
| 450 | /* POSIX.1b timers. */ |
| 451 | struct |
| 452 | { |
| 453 | unsigned int _timer1; |
| 454 | unsigned int _timer2; |
| 455 | } _timer; |
| 456 | |
| 457 | /* POSIX.1b signals. */ |
| 458 | struct |
| 459 | { |
| 460 | __pid_t si_pid; /* Sending process ID. */ |
| 461 | __uid_t si_uid; /* Real user ID of sending process. */ |
| 462 | sigval_t si_sigval; /* Signal value. */ |
| 463 | } _rt; |
| 464 | |
| 465 | /* SIGCHLD. */ |
| 466 | struct |
| 467 | { |
| 468 | __pid_t si_pid; /* Which child. */ |
| 469 | int si_status; /* Exit value or signal. */ |
| 470 | __clock_t si_utime; |
| 471 | __clock_t si_stime; |
| 472 | } _sigchld; |
| 473 | |
| 474 | /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */ |
| 475 | struct |
| 476 | { |
| 477 | void *si_addr; /* Faulting insn/memory ref. */ |
| 478 | } _sigfault; |
| 479 | |
| 480 | /* SIGPOLL. */ |
| 481 | struct |
| 482 | { |
| 483 | int si_band; /* Band event for SIGPOLL. */ |
| 484 | int si_fd; |
| 485 | } _sigpoll; |
| 486 | } _sifields; |
| 487 | } siginfo_t; |
| 488 | |
| 489 | #define si_pid _sifields._kill.si_pid |
| 490 | #define si_uid _sifields._kill.si_uid |
| 491 | #define si_status _sifields._sigchld.si_status |
| 492 | #define si_utime _sifields._sigchld.si_utime |
| 493 | #define si_stime _sifields._sigchld.si_stime |
| 494 | #define si_value _sifields._rt.si_sigval |
| 495 | #define si_int _sifields._rt.si_sigval.sival_int |
| 496 | #define si_ptr _sifields._rt.si_sigval.sival_ptr |
| 497 | #define si_addr _sifields._sigfault.si_addr |
| 498 | #define si_band _sifields._sigpoll.si_band |
| 499 | #define si_fd _sifields._sigpoll.si_fd |
| 500 | |
| 501 | #endif |
| 502 | |
| 503 | #endif |
| 504 | |
| 505 | #if defined (SVR4) || defined (LINUX) |
| 506 | |
| 507 | static struct xlat siginfo_codes[] = { |
| 508 | #ifdef SI_NOINFO |
| 509 | { SI_NOINFO, "SI_NOINFO" }, |
| 510 | #endif |
| 511 | #ifdef SI_USER |
| 512 | { SI_USER, "SI_USER" }, |
| 513 | #endif |
| 514 | #ifdef SI_LWP |
| 515 | { SI_LWP, "SI_LWP" }, |
| 516 | #endif |
| 517 | #ifdef SI_QUEUE |
| 518 | { SI_QUEUE, "SI_QUEUE" }, |
| 519 | #endif |
| 520 | #ifdef SI_TIMER |
| 521 | { SI_TIMER, "SI_TIMER" }, |
| 522 | #endif |
| 523 | #ifdef SI_ASYNCIO |
| 524 | { SI_ASYNCIO, "SI_ASYNCIO" }, |
| 525 | #endif |
| 526 | #ifdef SI_MESGQ |
| 527 | { SI_MESGQ, "SI_MESGQ" }, |
| 528 | #endif |
| 529 | { 0, NULL }, |
| 530 | }; |
| 531 | |
| 532 | static struct xlat sigill_codes[] = { |
| 533 | { ILL_ILLOPC, "ILL_ILLOPC" }, |
| 534 | { ILL_ILLOPN, "ILL_ILLOPN" }, |
| 535 | { ILL_ILLADR, "ILL_ILLADR" }, |
| 536 | { ILL_ILLTRP, "ILL_ILLTRP" }, |
| 537 | { ILL_PRVOPC, "ILL_PRVOPC" }, |
| 538 | { ILL_PRVREG, "ILL_PRVREG" }, |
| 539 | { ILL_COPROC, "ILL_COPROC" }, |
| 540 | { ILL_BADSTK, "ILL_BADSTK" }, |
| 541 | { 0, NULL }, |
| 542 | }; |
| 543 | |
| 544 | static struct xlat sigfpe_codes[] = { |
| 545 | { FPE_INTDIV, "FPE_INTDIV" }, |
| 546 | { FPE_INTOVF, "FPE_INTOVF" }, |
| 547 | { FPE_FLTDIV, "FPE_FLTDIV" }, |
| 548 | { FPE_FLTOVF, "FPE_FLTOVF" }, |
| 549 | { FPE_FLTUND, "FPE_FLTUND" }, |
| 550 | { FPE_FLTRES, "FPE_FLTRES" }, |
| 551 | { FPE_FLTINV, "FPE_FLTINV" }, |
| 552 | { FPE_FLTSUB, "FPE_FLTSUB" }, |
| 553 | { 0, NULL }, |
| 554 | }; |
| 555 | |
| 556 | static struct xlat sigtrap_codes[] = { |
| 557 | { TRAP_BRKPT, "TRAP_BRKPT" }, |
| 558 | { TRAP_TRACE, "TRAP_TRACE" }, |
| 559 | { 0, NULL }, |
| 560 | }; |
| 561 | |
| 562 | static struct xlat sigchld_codes[] = { |
| 563 | { CLD_EXITED, "CLD_EXITED" }, |
| 564 | { CLD_KILLED, "CLD_KILLED" }, |
| 565 | { CLD_DUMPED, "CLD_DUMPED" }, |
| 566 | { CLD_TRAPPED, "CLD_TRAPPED" }, |
| 567 | { CLD_STOPPED, "CLD_STOPPED" }, |
| 568 | { CLD_CONTINUED,"CLD_CONTINUED" }, |
| 569 | { 0, NULL }, |
| 570 | }; |
| 571 | |
| 572 | static struct xlat sigpoll_codes[] = { |
| 573 | { POLL_IN, "POLL_IN" }, |
| 574 | { POLL_OUT, "POLL_OUT" }, |
| 575 | { POLL_MSG, "POLL_MSG" }, |
| 576 | { POLL_ERR, "POLL_ERR" }, |
| 577 | { POLL_PRI, "POLL_PRI" }, |
| 578 | { POLL_HUP, "POLL_HUP" }, |
| 579 | { 0, NULL }, |
| 580 | }; |
| 581 | |
| 582 | static struct xlat sigprof_codes[] = { |
| 583 | #ifdef PROF_SIG |
| 584 | { PROF_SIG, "PROF_SIG" }, |
| 585 | #endif |
| 586 | { 0, NULL }, |
| 587 | }; |
| 588 | |
| 589 | #ifdef SIGEMT |
| 590 | static struct xlat sigemt_codes[] = { |
| 591 | #ifdef EMT_TAGOVF |
| 592 | { EMT_TAGOVF, "EMT_TAGOVF" }, |
| 593 | #endif |
| 594 | { 0, NULL }, |
| 595 | }; |
| 596 | #endif |
| 597 | |
| 598 | static struct xlat sigsegv_codes[] = { |
| 599 | { SEGV_MAPERR, "SEGV_MAPERR" }, |
| 600 | { SEGV_ACCERR, "SEGV_ACCERR" }, |
| 601 | { 0, NULL }, |
| 602 | }; |
| 603 | |
| 604 | static struct xlat sigbus_codes[] = { |
| 605 | { BUS_ADRALN, "BUS_ADRALN" }, |
| 606 | { BUS_ADRERR, "BUS_ADRERR" }, |
| 607 | { BUS_OBJERR, "BUS_OBJERR" }, |
| 608 | { 0, NULL }, |
| 609 | }; |
| 610 | |
| 611 | void |
| 612 | printsiginfo(sip, verbose) |
| 613 | siginfo_t *sip; |
| 614 | int verbose; |
| 615 | { |
| 616 | char *code; |
| 617 | |
| 618 | if (sip->si_signo == 0) { |
| 619 | tprintf ("{}"); |
| 620 | return; |
| 621 | } |
| 622 | tprintf("{si_signo="); |
| 623 | printsignal(sip->si_signo); |
| 624 | code = xlookup(siginfo_codes, sip->si_code); |
| 625 | if (!code) { |
| 626 | switch (sip->si_signo) { |
| 627 | case SIGTRAP: |
| 628 | code = xlookup(sigtrap_codes, sip->si_code); |
| 629 | break; |
| 630 | case SIGCHLD: |
| 631 | code = xlookup(sigchld_codes, sip->si_code); |
| 632 | break; |
| 633 | case SIGPOLL: |
| 634 | code = xlookup(sigpoll_codes, sip->si_code); |
| 635 | break; |
| 636 | case SIGPROF: |
| 637 | code = xlookup(sigprof_codes, sip->si_code); |
| 638 | break; |
| 639 | case SIGILL: |
| 640 | code = xlookup(sigill_codes, sip->si_code); |
| 641 | break; |
| 642 | #ifdef SIGEMT |
| 643 | case SIGEMT: |
| 644 | code = xlookup(sigemt_codes, sip->si_code); |
| 645 | break; |
| 646 | #endif |
| 647 | case SIGFPE: |
| 648 | code = xlookup(sigfpe_codes, sip->si_code); |
| 649 | break; |
| 650 | case SIGSEGV: |
| 651 | code = xlookup(sigsegv_codes, sip->si_code); |
| 652 | break; |
| 653 | case SIGBUS: |
| 654 | code = xlookup(sigbus_codes, sip->si_code); |
| 655 | break; |
| 656 | } |
| 657 | } |
| 658 | if (code) |
| 659 | tprintf(", si_code=%s", code); |
| 660 | else |
| 661 | tprintf(", si_code=%#x", sip->si_code); |
| 662 | #ifdef SI_NOINFO |
| 663 | if (sip->si_code != SI_NOINFO) |
| 664 | #endif |
| 665 | { |
| 666 | if (sip->si_errno) { |
| 667 | if (sip->si_errno < 0 || sip->si_errno >= nerrnos) |
| 668 | tprintf(", si_errno=%d", sip->si_errno); |
| 669 | else |
| 670 | tprintf(", si_errno=%s", |
| 671 | errnoent[sip->si_errno]); |
| 672 | } |
| 673 | #ifdef SI_FROMUSER |
| 674 | if (SI_FROMUSER(sip)) { |
| 675 | tprintf(", si_pid=%ld, si_uid=%ld", |
| 676 | sip->si_pid, sip->si_uid); |
| 677 | #ifdef SI_QUEUE |
| 678 | switch (sip->si_code) { |
| 679 | case SI_QUEUE: |
| 680 | #ifdef SI_TIMER |
| 681 | case SI_TIMER: |
| 682 | #endif /* SI_QUEUE */ |
| 683 | case SI_ASYNCIO: |
| 684 | #ifdef SI_MESGQ |
| 685 | case SI_MESGQ: |
| 686 | #endif /* SI_MESGQ */ |
| 687 | tprintf(", si_value=%d", |
| 688 | sip->si_value.sival_int); |
| 689 | break; |
| 690 | } |
| 691 | #endif /* SI_QUEUE */ |
| 692 | } |
| 693 | else |
| 694 | #endif /* SI_FROMUSER */ |
| 695 | { |
| 696 | switch (sip->si_signo) { |
| 697 | case SIGCHLD: |
| 698 | tprintf(", si_pid=%ld, si_status=", |
| 699 | (long) sip->si_pid); |
| 700 | if (sip->si_code == CLD_EXITED) |
| 701 | tprintf("%d", sip->si_status); |
| 702 | else |
| 703 | printsignal(sip->si_status); |
| 704 | #if LINUX |
| 705 | if (!verbose) |
| 706 | tprintf(", ..."); |
| 707 | else |
| 708 | tprintf(", si_utime=%lu, si_stime=%lu", |
| 709 | sip->si_utime, |
| 710 | sip->si_stime); |
| 711 | #endif |
| 712 | break; |
| 713 | case SIGILL: case SIGFPE: |
| 714 | case SIGSEGV: case SIGBUS: |
| 715 | tprintf(", si_addr=%#lx", |
| 716 | (unsigned long) sip->si_addr); |
| 717 | break; |
| 718 | case SIGPOLL: |
| 719 | switch (sip->si_code) { |
| 720 | case POLL_IN: case POLL_OUT: case POLL_MSG: |
| 721 | tprintf(", si_band=%ld", |
| 722 | (long) sip->si_band); |
| 723 | break; |
| 724 | } |
| 725 | break; |
| 726 | #ifdef LINUX |
| 727 | default: |
| 728 | tprintf(", si_pid=%lu, si_uid=%lu, ", |
| 729 | (unsigned long) sip->si_pid, |
| 730 | (unsigned long) sip->si_uid); |
| 731 | if (!verbose) |
| 732 | tprintf("..."); |
| 733 | else { |
| 734 | tprintf("si_value={int=%u, ptr=%#lx}", |
| 735 | sip->si_int, |
| 736 | (unsigned long) sip->si_ptr); |
| 737 | } |
| 738 | #endif |
Roland McGrath | a39c5a1 | 2002-12-17 05:10:37 +0000 | [diff] [blame^] | 739 | |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 740 | } |
| 741 | } |
| 742 | } |
| 743 | tprintf("}"); |
| 744 | } |
| 745 | |
| 746 | #endif /* SVR4 || LINUX */ |
| 747 | |
| 748 | #ifdef LINUX |
| 749 | |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 750 | static void |
| 751 | parse_sigset_t (const char *str, sigset_t *set) |
| 752 | { |
| 753 | unsigned int digit; |
| 754 | int i; |
| 755 | |
| 756 | sigemptyset(set); |
| 757 | |
| 758 | for (i = _NSIG - 4; i >= 0; i -= 4, ++str) { |
| 759 | if (*str >= 'a') |
| 760 | digit = (*str - 'a') + 10; |
| 761 | else |
| 762 | digit = *str - '0'; |
| 763 | if (digit & 1) |
| 764 | sigaddset(set, i + 1); |
| 765 | if (digit & 2) |
| 766 | sigaddset(set, i + 2); |
| 767 | if (digit & 4) |
| 768 | sigaddset(set, i + 3); |
| 769 | if (digit & 8) |
| 770 | sigaddset(set, i + 4); |
| 771 | } |
| 772 | } |
| 773 | |
| 774 | #endif |
| 775 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 776 | /* |
| 777 | * Check process TCP for the disposition of signal SIG. |
| 778 | * Return 1 if the process would somehow manage to survive signal SIG, |
| 779 | * else return 0. This routine will never be called with SIGKILL. |
| 780 | */ |
| 781 | int |
| 782 | sigishandled(tcp, sig) |
| 783 | struct tcb *tcp; |
| 784 | int sig; |
| 785 | { |
| 786 | #ifdef LINUX |
| 787 | int sfd; |
| 788 | char sname[32]; |
Wichert Akkerman | d5c2dae | 2001-04-12 09:10:24 +0000 | [diff] [blame] | 789 | char buf[2048]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 790 | char *s; |
| 791 | int i; |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 792 | sigset_t ignored, caught; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 793 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 794 | #ifdef SVR4 |
| 795 | /* |
| 796 | * Since procfs doesn't interfere with wait I think it is safe |
| 797 | * to punt on this question. If not, the information is there. |
| 798 | */ |
| 799 | return 1; |
| 800 | #else /* !SVR4 */ |
| 801 | switch (sig) { |
| 802 | case SIGCONT: |
| 803 | case SIGSTOP: |
| 804 | case SIGTSTP: |
| 805 | case SIGTTIN: |
| 806 | case SIGTTOU: |
| 807 | case SIGCHLD: |
| 808 | case SIGIO: |
| 809 | #if defined(SIGURG) && SIGURG != SIGIO |
| 810 | case SIGURG: |
| 811 | #endif |
| 812 | case SIGWINCH: |
| 813 | /* Gloria Gaynor says ... */ |
| 814 | return 1; |
| 815 | default: |
| 816 | break; |
| 817 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 818 | #endif /* !SVR4 */ |
Wichert Akkerman | d5c2dae | 2001-04-12 09:10:24 +0000 | [diff] [blame] | 819 | #ifdef LINUX |
| 820 | |
| 821 | /* This is incredibly costly but it's worth it. */ |
| 822 | /* NOTE: LinuxThreads internally uses SIGRTMIN, SIGRTMIN + 1 and |
| 823 | SIGRTMIN + 2, so we can't use the obsolete /proc/%d/stat which |
| 824 | doesn't handle real-time signals). */ |
| 825 | sprintf(sname, "/proc/%d/status", tcp->pid); |
| 826 | if ((sfd = open(sname, O_RDONLY)) == -1) { |
| 827 | perror(sname); |
| 828 | return 1; |
| 829 | } |
| 830 | i = read(sfd, buf, sizeof(buf)); |
| 831 | buf[i] = '\0'; |
| 832 | close(sfd); |
| 833 | /* |
| 834 | * Skip the extraneous fields. We need to skip |
| 835 | * command name has any spaces in it. So be it. |
| 836 | */ |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 837 | s = strstr(buf, "SigIgn:\t"); |
Wichert Akkerman | d5c2dae | 2001-04-12 09:10:24 +0000 | [diff] [blame] | 838 | if (!s) |
| 839 | { |
| 840 | fprintf(stderr, "/proc/pid/status format error\n"); |
| 841 | return 1; |
| 842 | } |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 843 | parse_sigset_t(s + 8, &ignored); |
Wichert Akkerman | d5c2dae | 2001-04-12 09:10:24 +0000 | [diff] [blame] | 844 | |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 845 | s = strstr(buf, "SigCgt:\t"); |
| 846 | if (!s) |
| 847 | { |
| 848 | fprintf(stderr, "/proc/pid/status format error\n"); |
| 849 | return 1; |
| 850 | } |
| 851 | parse_sigset_t(s + 8, &caught); |
Wichert Akkerman | d5c2dae | 2001-04-12 09:10:24 +0000 | [diff] [blame] | 852 | |
| 853 | #ifdef DEBUG |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 854 | fprintf(stderr, "sigs: %016qx %016qx (sig=%d)\n", |
| 855 | *(long long *) &ignored, *(long long *) &caught, sig); |
Wichert Akkerman | d5c2dae | 2001-04-12 09:10:24 +0000 | [diff] [blame] | 856 | #endif |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 857 | if (sigismember(&ignored, sig) || sigismember(&caught, sig)) |
Wichert Akkerman | d5c2dae | 2001-04-12 09:10:24 +0000 | [diff] [blame] | 858 | return 1; |
| 859 | #endif /* LINUX */ |
| 860 | |
| 861 | #ifdef SUNOS4 |
| 862 | void (*u_signal)(); |
| 863 | |
| 864 | if (upeek(tcp->pid, uoff(u_signal[0]) + sig*sizeof(u_signal), |
| 865 | (long *) &u_signal) < 0) { |
| 866 | return 0; |
| 867 | } |
| 868 | if (u_signal != SIG_DFL) |
| 869 | return 1; |
| 870 | #endif /* SUNOS4 */ |
| 871 | |
| 872 | return 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 873 | } |
| 874 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 875 | #if defined(SUNOS4) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 876 | |
| 877 | int |
| 878 | sys_sigvec(tcp) |
| 879 | struct tcb *tcp; |
| 880 | { |
| 881 | struct sigvec sv; |
| 882 | long addr; |
| 883 | |
| 884 | if (entering(tcp)) { |
| 885 | printsignal(tcp->u_arg[0]); |
| 886 | tprintf(", "); |
| 887 | addr = tcp->u_arg[1]; |
| 888 | } else { |
| 889 | addr = tcp->u_arg[2]; |
| 890 | } |
| 891 | if (addr == 0) |
| 892 | tprintf("NULL"); |
| 893 | else if (!verbose(tcp)) |
| 894 | tprintf("%#lx", addr); |
| 895 | else if (umove(tcp, addr, &sv) < 0) |
| 896 | tprintf("{...}"); |
| 897 | else { |
| 898 | switch ((int) sv.sv_handler) { |
| 899 | case (int) SIG_ERR: |
| 900 | tprintf("{SIG_ERR}"); |
| 901 | break; |
| 902 | case (int) SIG_DFL: |
| 903 | tprintf("{SIG_DFL}"); |
| 904 | break; |
| 905 | case (int) SIG_IGN: |
| 906 | if (tcp->u_arg[0] == SIGTRAP) { |
| 907 | tcp->flags |= TCB_SIGTRAPPED; |
| 908 | kill(tcp->pid, SIGSTOP); |
| 909 | } |
| 910 | tprintf("{SIG_IGN}"); |
| 911 | break; |
| 912 | case (int) SIG_HOLD: |
| 913 | if (tcp->u_arg[0] == SIGTRAP) { |
| 914 | tcp->flags |= TCB_SIGTRAPPED; |
| 915 | kill(tcp->pid, SIGSTOP); |
| 916 | } |
| 917 | tprintf("SIG_HOLD"); |
| 918 | break; |
| 919 | default: |
| 920 | if (tcp->u_arg[0] == SIGTRAP) { |
| 921 | tcp->flags |= TCB_SIGTRAPPED; |
| 922 | kill(tcp->pid, SIGSTOP); |
| 923 | } |
| 924 | tprintf("{%#lx, ", (unsigned long) sv.sv_handler); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 925 | printsigmask(&sv.sv_mask, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 926 | tprintf(", "); |
| 927 | if (!printflags(sigvec_flags, sv.sv_flags)) |
| 928 | tprintf("0"); |
| 929 | tprintf("}"); |
| 930 | } |
| 931 | } |
| 932 | if (entering(tcp)) |
| 933 | tprintf(", "); |
| 934 | return 0; |
| 935 | } |
| 936 | |
| 937 | int |
| 938 | sys_sigpause(tcp) |
| 939 | struct tcb *tcp; |
| 940 | { |
| 941 | 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] | 942 | sigset_t sigm; |
| 943 | long_to_sigset(tcp->u_arg[0], &sigm); |
| 944 | printsigmask(&sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 945 | } |
| 946 | return 0; |
| 947 | } |
| 948 | |
| 949 | int |
| 950 | sys_sigstack(tcp) |
| 951 | struct tcb *tcp; |
| 952 | { |
| 953 | struct sigstack ss; |
| 954 | long addr; |
| 955 | |
| 956 | if (entering(tcp)) |
| 957 | addr = tcp->u_arg[0]; |
| 958 | else |
| 959 | addr = tcp->u_arg[1]; |
| 960 | if (addr == 0) |
| 961 | tprintf("NULL"); |
| 962 | else if (umove(tcp, addr, &ss) < 0) |
| 963 | tprintf("%#lx", addr); |
| 964 | else { |
| 965 | tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp); |
| 966 | tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO"); |
| 967 | } |
| 968 | if (entering(tcp)) |
| 969 | tprintf(", "); |
| 970 | return 0; |
| 971 | } |
| 972 | |
| 973 | int |
| 974 | sys_sigcleanup(tcp) |
| 975 | struct tcb *tcp; |
| 976 | { |
| 977 | return 0; |
| 978 | } |
| 979 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 980 | #endif /* SUNOS4 || FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 981 | |
| 982 | #ifndef SVR4 |
| 983 | |
| 984 | int |
| 985 | sys_sigsetmask(tcp) |
| 986 | struct tcb *tcp; |
| 987 | { |
| 988 | if (entering(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 989 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 990 | long_to_sigset(tcp->u_arg[0], &sigm); |
| 991 | printsigmask(&sigm, 0); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 992 | #ifndef USE_PROCFS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 993 | if ((tcp->u_arg[0] & sigmask(SIGTRAP))) { |
| 994 | /* Mark attempt to block SIGTRAP */ |
| 995 | tcp->flags |= TCB_SIGTRAPPED; |
| 996 | /* Send unblockable signal */ |
| 997 | kill(tcp->pid, SIGSTOP); |
| 998 | } |
Roland McGrath | a39c5a1 | 2002-12-17 05:10:37 +0000 | [diff] [blame^] | 999 | #endif /* !USE_PROCFS */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1000 | } |
| 1001 | else if (!syserror(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1002 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1003 | long_to_sigset(tcp->u_rval, &sigm); |
| 1004 | tcp->auxstr = sprintsigmask("old mask ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1005 | |
| 1006 | return RVAL_HEX | RVAL_STR; |
| 1007 | } |
| 1008 | return 0; |
| 1009 | } |
| 1010 | |
| 1011 | int |
| 1012 | sys_sigblock(tcp) |
| 1013 | struct tcb *tcp; |
| 1014 | { |
| 1015 | return sys_sigsetmask(tcp); |
| 1016 | } |
| 1017 | |
| 1018 | #endif /* !SVR4 */ |
| 1019 | |
| 1020 | #ifdef HAVE_SIGACTION |
| 1021 | |
| 1022 | #ifdef LINUX |
| 1023 | struct old_sigaction { |
| 1024 | __sighandler_t __sa_handler; |
| 1025 | unsigned long sa_mask; |
| 1026 | unsigned long sa_flags; |
| 1027 | void (*sa_restorer)(void); |
| 1028 | }; |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1029 | #define SA_HANDLER __sa_handler |
| 1030 | #endif /* LINUX */ |
| 1031 | |
Roland McGrath | a39c5a1 | 2002-12-17 05:10:37 +0000 | [diff] [blame^] | 1032 | #ifndef SA_HANDLER |
| 1033 | #define SA_HANDLER sa_handler |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1034 | #endif |
| 1035 | |
| 1036 | int |
| 1037 | sys_sigaction(tcp) |
| 1038 | struct tcb *tcp; |
| 1039 | { |
| 1040 | long addr; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1041 | #ifdef LINUX |
John Hughes | 1e4cb34 | 2001-03-06 09:25:46 +0000 | [diff] [blame] | 1042 | sigset_t sigset; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1043 | struct old_sigaction sa; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1044 | #else |
| 1045 | struct sigaction sa; |
| 1046 | #endif |
| 1047 | |
| 1048 | |
| 1049 | if (entering(tcp)) { |
| 1050 | printsignal(tcp->u_arg[0]); |
| 1051 | tprintf(", "); |
| 1052 | addr = tcp->u_arg[1]; |
| 1053 | } else |
| 1054 | addr = tcp->u_arg[2]; |
| 1055 | if (addr == 0) |
| 1056 | tprintf("NULL"); |
| 1057 | else if (!verbose(tcp)) |
| 1058 | tprintf("%#lx", addr); |
| 1059 | else if (umove(tcp, addr, &sa) < 0) |
| 1060 | tprintf("{...}"); |
| 1061 | else { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1062 | switch ((long) sa.SA_HANDLER) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1063 | case (long) SIG_ERR: |
| 1064 | tprintf("{SIG_ERR}"); |
| 1065 | break; |
| 1066 | case (long) SIG_DFL: |
| 1067 | tprintf("{SIG_DFL}"); |
| 1068 | break; |
| 1069 | case (long) SIG_IGN: |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1070 | #ifndef USE_PROCFS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1071 | if (tcp->u_arg[0] == SIGTRAP) { |
| 1072 | tcp->flags |= TCB_SIGTRAPPED; |
| 1073 | kill(tcp->pid, SIGSTOP); |
| 1074 | } |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1075 | #endif /* !USE_PROCFS */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1076 | tprintf("{SIG_IGN}"); |
| 1077 | break; |
| 1078 | default: |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1079 | #ifndef USE_PROCFS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1080 | if (tcp->u_arg[0] == SIGTRAP) { |
| 1081 | tcp->flags |= TCB_SIGTRAPPED; |
| 1082 | kill(tcp->pid, SIGSTOP); |
| 1083 | } |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1084 | #endif /* !USE_PROCFS */ |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1085 | tprintf("{%#lx, ", (long) sa.SA_HANDLER); |
Wichert Akkerman | 48214be | 1999-11-26 09:55:42 +0000 | [diff] [blame] | 1086 | #ifndef LINUX |
| 1087 | printsigmask (&sa.sa_mask, 0); |
| 1088 | #else |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1089 | long_to_sigset(sa.sa_mask, &sigset); |
| 1090 | printsigmask(&sigset, 0); |
Wichert Akkerman | 48214be | 1999-11-26 09:55:42 +0000 | [diff] [blame] | 1091 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1092 | tprintf(", "); |
| 1093 | if (!printflags(sigact_flags, sa.sa_flags)) |
| 1094 | tprintf("0"); |
Roland McGrath | 2638cb4 | 2002-12-15 23:58:41 +0000 | [diff] [blame] | 1095 | #ifdef SA_RESTORER |
| 1096 | if (sa.sa_flags & SA_RESTORER) |
| 1097 | tprintf(", %p", sa.sa_restorer); |
| 1098 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1099 | tprintf("}"); |
| 1100 | } |
| 1101 | } |
| 1102 | if (entering(tcp)) |
| 1103 | tprintf(", "); |
| 1104 | #ifdef LINUX |
| 1105 | else |
| 1106 | tprintf(", %#lx", (unsigned long) sa.sa_restorer); |
| 1107 | #endif |
| 1108 | return 0; |
| 1109 | } |
| 1110 | |
| 1111 | int |
| 1112 | sys_signal(tcp) |
| 1113 | struct tcb *tcp; |
| 1114 | { |
| 1115 | if (entering(tcp)) { |
| 1116 | printsignal(tcp->u_arg[0]); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 1117 | tprintf(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1118 | switch (tcp->u_arg[1]) { |
| 1119 | case (int) SIG_ERR: |
| 1120 | tprintf("SIG_ERR"); |
| 1121 | break; |
| 1122 | case (int) SIG_DFL: |
| 1123 | tprintf("SIG_DFL"); |
| 1124 | break; |
| 1125 | case (int) SIG_IGN: |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1126 | #ifndef USE_PROCFS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1127 | if (tcp->u_arg[0] == SIGTRAP) { |
| 1128 | tcp->flags |= TCB_SIGTRAPPED; |
| 1129 | kill(tcp->pid, SIGSTOP); |
| 1130 | } |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1131 | #endif /* !USE_PROCFS */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1132 | tprintf("SIG_IGN"); |
| 1133 | break; |
| 1134 | default: |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1135 | #ifndef USE_PROCFS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1136 | if (tcp->u_arg[0] == SIGTRAP) { |
| 1137 | tcp->flags |= TCB_SIGTRAPPED; |
| 1138 | kill(tcp->pid, SIGSTOP); |
| 1139 | } |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1140 | #endif /* !USE_PROCFS */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1141 | tprintf("%#lx", tcp->u_arg[1]); |
| 1142 | } |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 1143 | return 0; |
| 1144 | } |
| 1145 | else { |
| 1146 | switch (tcp->u_rval) { |
| 1147 | case (int) SIG_ERR: |
| 1148 | tcp->auxstr = "SIG_ERR"; break; |
| 1149 | case (int) SIG_DFL: |
| 1150 | tcp->auxstr = "SIG_DFL"; break; |
| 1151 | case (int) SIG_IGN: |
| 1152 | tcp->auxstr = "SIG_IGN"; break; |
| 1153 | default: |
| 1154 | tcp->auxstr = NULL; |
| 1155 | } |
| 1156 | return RVAL_HEX | RVAL_STR; |
| 1157 | } |
| 1158 | } |
| 1159 | |
| 1160 | int |
| 1161 | sys_sighold(tcp) |
| 1162 | struct tcb *tcp; |
| 1163 | { |
| 1164 | if (entering(tcp)) { |
| 1165 | printsignal(tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1166 | } |
| 1167 | return 0; |
| 1168 | } |
| 1169 | |
| 1170 | #endif /* HAVE_SIGACTION */ |
| 1171 | |
| 1172 | #ifdef LINUX |
| 1173 | |
| 1174 | int |
| 1175 | sys_sigreturn(tcp) |
| 1176 | struct tcb *tcp; |
| 1177 | { |
Michal Ludvig | 10a88d0 | 2002-10-07 14:31:00 +0000 | [diff] [blame] | 1178 | #if defined(S390) || defined(S390X) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 1179 | long usp; |
| 1180 | struct sigcontext_struct sc; |
| 1181 | |
| 1182 | if (entering(tcp)) { |
| 1183 | tcp->u_arg[0] = 0; |
| 1184 | if (upeek(tcp->pid,PT_GPR15,&usp)<0) |
| 1185 | return 0; |
| 1186 | if (umove(tcp, usp+__SIGNAL_FRAMESIZE, &sc) < 0) |
| 1187 | return 0; |
| 1188 | tcp->u_arg[0] = 1; |
| 1189 | memcpy(&tcp->u_arg[1],&sc.oldmask[0],sizeof(sigset_t)); |
| 1190 | } else { |
| 1191 | tcp->u_rval = tcp->u_error = 0; |
| 1192 | if (tcp->u_arg[0] == 0) |
| 1193 | return 0; |
Michal Ludvig | 10a88d0 | 2002-10-07 14:31:00 +0000 | [diff] [blame] | 1194 | tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1],0); |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 1195 | return RVAL_NONE | RVAL_STR; |
| 1196 | } |
| 1197 | return 0; |
| 1198 | #else |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1199 | #ifdef I386 |
| 1200 | long esp; |
| 1201 | struct sigcontext_struct sc; |
| 1202 | |
| 1203 | if (entering(tcp)) { |
| 1204 | tcp->u_arg[0] = 0; |
| 1205 | if (upeek(tcp->pid, 4*UESP, &esp) < 0) |
| 1206 | return 0; |
| 1207 | if (umove(tcp, esp, &sc) < 0) |
| 1208 | return 0; |
| 1209 | tcp->u_arg[0] = 1; |
| 1210 | tcp->u_arg[1] = sc.oldmask; |
| 1211 | } |
| 1212 | else { |
| 1213 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1214 | long_to_sigset(tcp->u_arg[1], &sigm); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1215 | tcp->u_rval = tcp->u_error = 0; |
| 1216 | if (tcp->u_arg[0] == 0) |
| 1217 | return 0; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1218 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1219 | return RVAL_NONE | RVAL_STR; |
| 1220 | } |
| 1221 | return 0; |
| 1222 | #else /* !I386 */ |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1223 | #ifdef IA64 |
| 1224 | struct sigcontext sc; |
| 1225 | long sp; |
| 1226 | |
| 1227 | if (entering(tcp)) { |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 1228 | /* offset of sigcontext in the kernel's sigframe structure: */ |
| 1229 | # define SIGFRAME_SC_OFFSET 0x90 |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1230 | tcp->u_arg[0] = 0; |
| 1231 | if (upeek(tcp->pid, PT_R12, &sp) < 0) |
| 1232 | return 0; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 1233 | if (umove(tcp, sp + 16 + SIGFRAME_SC_OFFSET, &sc) < 0) |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1234 | return 0; |
| 1235 | tcp->u_arg[0] = 1; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 1236 | memcpy(tcp->u_arg + 1, &sc.sc_mask, sizeof(sc.sc_mask)); |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1237 | } |
| 1238 | else { |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 1239 | sigset_t sigm; |
| 1240 | |
| 1241 | memcpy(&sigm, tcp->u_arg + 1, sizeof (sigm)); |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1242 | tcp->u_rval = tcp->u_error = 0; |
| 1243 | if (tcp->u_arg[0] == 0) |
| 1244 | return 0; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 1245 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1246 | return RVAL_NONE | RVAL_STR; |
| 1247 | } |
| 1248 | return 0; |
| 1249 | #else /* !IA64 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1250 | #ifdef POWERPC |
| 1251 | long esp; |
| 1252 | struct sigcontext_struct sc; |
| 1253 | |
| 1254 | if (entering(tcp)) { |
| 1255 | tcp->u_arg[0] = 0; |
| 1256 | if (upeek(tcp->pid, 4*PT_R1, &esp) < 0) |
| 1257 | return 0; |
| 1258 | if (umove(tcp, esp, &sc) < 0) |
| 1259 | return 0; |
| 1260 | tcp->u_arg[0] = 1; |
| 1261 | tcp->u_arg[1] = sc.oldmask; |
| 1262 | } |
| 1263 | else { |
| 1264 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1265 | long_to_sigset(tcp->u_arg[1], &sigm); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1266 | tcp->u_rval = tcp->u_error = 0; |
| 1267 | if (tcp->u_arg[0] == 0) |
| 1268 | return 0; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1269 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1270 | return RVAL_NONE | RVAL_STR; |
| 1271 | } |
| 1272 | return 0; |
| 1273 | #else /* !POWERPC */ |
| 1274 | #ifdef M68K |
| 1275 | long usp; |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1276 | struct sigcontext sc; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1277 | |
| 1278 | if (entering(tcp)) { |
| 1279 | tcp->u_arg[0] = 0; |
| 1280 | if (upeek(tcp->pid, 4*PT_USP, &usp) < 0) |
| 1281 | return 0; |
| 1282 | if (umove(tcp, usp, &sc) < 0) |
| 1283 | return 0; |
| 1284 | tcp->u_arg[0] = 1; |
| 1285 | tcp->u_arg[1] = sc.sc_mask; |
| 1286 | } |
| 1287 | else { |
| 1288 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1289 | long_to_sigset(tcp->u_arg[1], &sigm); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1290 | tcp->u_rval = tcp->u_error = 0; |
| 1291 | if (tcp->u_arg[0] == 0) |
| 1292 | return 0; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1293 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1294 | return RVAL_NONE | RVAL_STR; |
| 1295 | } |
| 1296 | return 0; |
| 1297 | #else /* !M68K */ |
| 1298 | #ifdef ALPHA |
| 1299 | long fp; |
| 1300 | struct sigcontext_struct sc; |
| 1301 | |
| 1302 | if (entering(tcp)) { |
| 1303 | tcp->u_arg[0] = 0; |
| 1304 | if (upeek(tcp->pid, REG_FP, &fp) < 0) |
| 1305 | return 0; |
| 1306 | if (umove(tcp, fp, &sc) < 0) |
| 1307 | return 0; |
| 1308 | tcp->u_arg[0] = 1; |
| 1309 | tcp->u_arg[1] = sc.sc_mask; |
| 1310 | } |
| 1311 | else { |
| 1312 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1313 | long_to_sigset(tcp->u_arg[1], &sigm); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1314 | tcp->u_rval = tcp->u_error = 0; |
| 1315 | if (tcp->u_arg[0] == 0) |
| 1316 | return 0; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1317 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1318 | return RVAL_NONE | RVAL_STR; |
| 1319 | } |
| 1320 | return 0; |
| 1321 | #else |
| 1322 | #ifdef SPARC |
| 1323 | long i1; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 1324 | struct regs regs; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1325 | m_siginfo_t si; |
| 1326 | |
| 1327 | if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) { |
| 1328 | perror("sigreturn: PTRACE_GETREGS "); |
| 1329 | return 0; |
| 1330 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1331 | if(entering(tcp)) { |
| 1332 | tcp->u_arg[0] = 0; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 1333 | i1 = regs.r_o1; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1334 | if(umove(tcp, i1, &si) < 0) { |
| 1335 | perror("sigreturn: umove "); |
| 1336 | return 0; |
| 1337 | } |
| 1338 | tcp->u_arg[0] = 1; |
| 1339 | tcp->u_arg[1] = si.si_mask; |
| 1340 | } else { |
| 1341 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1342 | long_to_sigset(tcp->u_arg[1], &sigm); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1343 | tcp->u_rval = tcp->u_error = 0; |
| 1344 | if(tcp->u_arg[0] == 0) |
| 1345 | return 0; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1346 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1347 | return RVAL_NONE | RVAL_STR; |
| 1348 | } |
| 1349 | return 0; |
Roland McGrath | a39c5a1 | 2002-12-17 05:10:37 +0000 | [diff] [blame^] | 1350 | #else |
Wichert Akkerman | f90da01 | 1999-10-31 21:15:38 +0000 | [diff] [blame] | 1351 | #ifdef MIPS |
| 1352 | long sp; |
| 1353 | struct sigcontext sc; |
| 1354 | |
| 1355 | if(entering(tcp)) { |
| 1356 | tcp->u_arg[0] = 0; |
| 1357 | if (upeek(tcp->pid, REG_SP, &sp) < 0) |
| 1358 | return 0; |
| 1359 | if (umove(tcp, sp, &sc) < 0) |
| 1360 | return 0; |
| 1361 | tcp->u_arg[0] = 1; |
| 1362 | tcp->u_arg[1] = sc.sc_sigset; |
| 1363 | } else { |
| 1364 | tcp->u_rval = tcp->u_error = 0; |
| 1365 | if(tcp->u_arg[0] == 0) |
| 1366 | return 0; |
| 1367 | tcp->auxstr = sprintsigmask("mask now ", tcp->u_arg[1]); |
| 1368 | return RVAL_NONE | RVAL_STR; |
| 1369 | } |
| 1370 | return 0; |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 1371 | #else |
Michal Ludvig | 0e03550 | 2002-09-23 15:41:01 +0000 | [diff] [blame] | 1372 | #warning No sys_sigreturn() for this architecture |
| 1373 | #warning (no problem, just a reminder :-) |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 1374 | return 0; |
Wichert Akkerman | f90da01 | 1999-10-31 21:15:38 +0000 | [diff] [blame] | 1375 | #endif /* MIPS */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1376 | #endif /* SPARC */ |
| 1377 | #endif /* ALPHA */ |
| 1378 | #endif /* !M68K */ |
| 1379 | #endif /* !POWERPC */ |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1380 | #endif /* !IA64 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1381 | #endif /* !I386 */ |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 1382 | #endif /* S390 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1383 | } |
| 1384 | |
| 1385 | int |
| 1386 | sys_siggetmask(tcp) |
| 1387 | struct tcb *tcp; |
| 1388 | { |
| 1389 | if (exiting(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1390 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1391 | long_to_sigset(tcp->u_rval, &sigm); |
| 1392 | tcp->auxstr = sprintsigmask("mask ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1393 | } |
| 1394 | return RVAL_HEX | RVAL_STR; |
| 1395 | } |
| 1396 | |
| 1397 | int |
| 1398 | sys_sigsuspend(tcp) |
| 1399 | struct tcb *tcp; |
| 1400 | { |
| 1401 | if (entering(tcp)) { |
| 1402 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1403 | long_to_sigset(tcp->u_arg[2], &sigm); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1404 | #if 0 |
| 1405 | /* first two are not really arguments, but print them anyway */ |
| 1406 | /* nevermind, they are an anachronism now, too bad... */ |
| 1407 | tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 1408 | #endif |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1409 | printsigmask(&sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1410 | } |
| 1411 | return 0; |
| 1412 | } |
| 1413 | |
| 1414 | #endif /* LINUX */ |
| 1415 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1416 | #if defined(SVR4) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1417 | |
| 1418 | int |
| 1419 | sys_sigsuspend(tcp) |
| 1420 | struct tcb *tcp; |
| 1421 | { |
| 1422 | sigset_t sigset; |
| 1423 | |
| 1424 | if (entering(tcp)) { |
| 1425 | if (umove(tcp, tcp->u_arg[0], &sigset) < 0) |
| 1426 | tprintf("[?]"); |
| 1427 | else |
Wichert Akkerman | 4695657 | 1999-11-26 10:12:59 +0000 | [diff] [blame] | 1428 | printsigmask(&sigset, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1429 | } |
| 1430 | return 0; |
| 1431 | } |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1432 | #ifndef FREEBSD |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1433 | static struct xlat ucontext_flags[] = { |
| 1434 | { UC_SIGMASK, "UC_SIGMASK" }, |
| 1435 | { UC_STACK, "UC_STACK" }, |
| 1436 | { UC_CPU, "UC_CPU" }, |
| 1437 | #ifdef UC_FPU |
| 1438 | { UC_FPU, "UC_FPU" }, |
| 1439 | #endif |
| 1440 | #ifdef UC_INTR |
| 1441 | { UC_INTR, "UC_INTR" }, |
| 1442 | #endif |
| 1443 | { 0, NULL }, |
| 1444 | }; |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1445 | #endif /* !FREEBSD */ |
| 1446 | #endif /* SVR4 || FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1447 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1448 | #if defined SVR4 || defined LINUX || defined FREEBSD |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1449 | #if defined LINUX && !defined SS_ONSTACK |
| 1450 | #define SS_ONSTACK 1 |
| 1451 | #define SS_DISABLE 2 |
| 1452 | #if __GLIBC_MINOR__ == 0 |
| 1453 | typedef struct |
| 1454 | { |
| 1455 | __ptr_t ss_sp; |
| 1456 | int ss_flags; |
| 1457 | size_t ss_size; |
| 1458 | } stack_t; |
| 1459 | #endif |
| 1460 | #endif |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1461 | #ifdef FREEBSD |
| 1462 | #define stack_t struct sigaltstack |
| 1463 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1464 | |
| 1465 | static struct xlat sigaltstack_flags[] = { |
| 1466 | { SS_ONSTACK, "SS_ONSTACK" }, |
| 1467 | { SS_DISABLE, "SS_DISABLE" }, |
| 1468 | { 0, NULL }, |
| 1469 | }; |
| 1470 | #endif |
| 1471 | |
| 1472 | #ifdef SVR4 |
| 1473 | static void |
| 1474 | printcontext(tcp, ucp) |
| 1475 | struct tcb *tcp; |
| 1476 | ucontext_t *ucp; |
| 1477 | { |
| 1478 | tprintf("{"); |
| 1479 | if (!abbrev(tcp)) { |
| 1480 | tprintf("uc_flags="); |
| 1481 | if (!printflags(ucontext_flags, ucp->uc_flags)) |
| 1482 | tprintf("0"); |
| 1483 | tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link); |
| 1484 | } |
| 1485 | tprintf("uc_sigmask="); |
John Hughes | 70c5e7a | 2001-05-15 15:09:14 +0000 | [diff] [blame] | 1486 | printsigmask(&ucp->uc_sigmask, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1487 | if (!abbrev(tcp)) { |
| 1488 | tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=", |
| 1489 | (unsigned long) ucp->uc_stack.ss_sp, |
| 1490 | ucp->uc_stack.ss_size); |
| 1491 | if (!printflags(sigaltstack_flags, ucp->uc_stack.ss_flags)) |
| 1492 | tprintf("0"); |
| 1493 | tprintf("}"); |
| 1494 | } |
| 1495 | tprintf(", ...}"); |
| 1496 | } |
| 1497 | |
| 1498 | int |
| 1499 | sys_getcontext(tcp) |
| 1500 | struct tcb *tcp; |
| 1501 | { |
| 1502 | ucontext_t uc; |
| 1503 | |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 1504 | if (exiting(tcp)) { |
| 1505 | if (tcp->u_error) |
| 1506 | tprintf("%#lx", tcp->u_arg[0]); |
| 1507 | else if (!tcp->u_arg[0]) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1508 | tprintf("NULL"); |
| 1509 | else if (umove(tcp, tcp->u_arg[0], &uc) < 0) |
| 1510 | tprintf("{...}"); |
| 1511 | else |
| 1512 | printcontext(tcp, &uc); |
| 1513 | } |
| 1514 | return 0; |
| 1515 | } |
| 1516 | |
| 1517 | int |
| 1518 | sys_setcontext(tcp) |
| 1519 | struct tcb *tcp; |
| 1520 | { |
| 1521 | ucontext_t uc; |
| 1522 | |
| 1523 | if (entering(tcp)) { |
| 1524 | if (!tcp->u_arg[0]) |
| 1525 | tprintf("NULL"); |
| 1526 | else if (umove(tcp, tcp->u_arg[0], &uc) < 0) |
| 1527 | tprintf("{...}"); |
| 1528 | else |
| 1529 | printcontext(tcp, &uc); |
| 1530 | } |
| 1531 | else { |
| 1532 | tcp->u_rval = tcp->u_error = 0; |
| 1533 | if (tcp->u_arg[0] == 0) |
| 1534 | return 0; |
| 1535 | return RVAL_NONE; |
| 1536 | } |
| 1537 | return 0; |
| 1538 | } |
| 1539 | |
| 1540 | #endif /* SVR4 */ |
| 1541 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1542 | #if defined(LINUX) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1543 | |
| 1544 | static int |
| 1545 | print_stack_t(tcp, addr) |
| 1546 | struct tcb *tcp; |
| 1547 | unsigned long addr; |
| 1548 | { |
| 1549 | stack_t ss; |
| 1550 | if (umove(tcp, addr, &ss) < 0) |
| 1551 | return -1; |
| 1552 | tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp); |
| 1553 | if (!printflags(sigaltstack_flags, ss.ss_flags)) |
| 1554 | tprintf("0"); |
| 1555 | tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size); |
| 1556 | return 0; |
| 1557 | } |
| 1558 | |
| 1559 | int |
| 1560 | sys_sigaltstack(tcp) |
| 1561 | struct tcb *tcp; |
| 1562 | { |
| 1563 | if (entering(tcp)) { |
| 1564 | if (tcp->u_arg[0] == 0) |
| 1565 | tprintf("NULL"); |
| 1566 | else if (print_stack_t(tcp, tcp->u_arg[0]) < 0) |
| 1567 | return -1; |
| 1568 | } |
| 1569 | else { |
| 1570 | tprintf(", "); |
| 1571 | if (tcp->u_arg[1] == 0) |
| 1572 | tprintf("NULL"); |
| 1573 | else if (print_stack_t(tcp, tcp->u_arg[1]) < 0) |
| 1574 | return -1; |
| 1575 | } |
| 1576 | return 0; |
| 1577 | } |
| 1578 | #endif |
| 1579 | |
| 1580 | #ifdef HAVE_SIGACTION |
| 1581 | |
| 1582 | int |
| 1583 | sys_sigprocmask(tcp) |
| 1584 | struct tcb *tcp; |
| 1585 | { |
| 1586 | #ifdef ALPHA |
| 1587 | if (entering(tcp)) { |
| 1588 | printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???"); |
| 1589 | tprintf(", "); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1590 | printsigmask(tcp->u_arg[1], 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1591 | } |
| 1592 | else if (!syserror(tcp)) { |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1593 | tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1594 | return RVAL_HEX | RVAL_STR; |
| 1595 | } |
| 1596 | #else /* !ALPHA */ |
| 1597 | sigset_t sigset; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1598 | |
| 1599 | if (entering(tcp)) { |
| 1600 | #ifdef SVR4 |
| 1601 | if (tcp->u_arg[0] == 0) |
| 1602 | tprintf("0"); |
| 1603 | else |
| 1604 | #endif /* SVR4 */ |
| 1605 | printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???"); |
| 1606 | tprintf(", "); |
| 1607 | if (!tcp->u_arg[1]) |
| 1608 | tprintf("NULL, "); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1609 | else if (copy_sigset(tcp, tcp->u_arg[1], &sigset) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1610 | tprintf("%#lx, ", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1611 | else { |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1612 | printsigmask(&sigset, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1613 | tprintf(", "); |
| 1614 | } |
| 1615 | } |
| 1616 | else { |
| 1617 | if (!tcp->u_arg[2]) |
| 1618 | tprintf("NULL"); |
| 1619 | else if (syserror(tcp)) |
| 1620 | tprintf("%#lx", tcp->u_arg[2]); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1621 | else if (copy_sigset(tcp, tcp->u_arg[2], &sigset) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1622 | tprintf("[?]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1623 | else |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1624 | printsigmask(&sigset, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1625 | } |
| 1626 | #endif /* !ALPHA */ |
| 1627 | return 0; |
| 1628 | } |
| 1629 | |
| 1630 | #endif /* HAVE_SIGACTION */ |
| 1631 | |
| 1632 | int |
| 1633 | sys_kill(tcp) |
| 1634 | struct tcb *tcp; |
| 1635 | { |
| 1636 | if (entering(tcp)) { |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 1637 | tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1])); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1638 | } |
| 1639 | return 0; |
| 1640 | } |
| 1641 | |
| 1642 | int |
| 1643 | sys_killpg(tcp) |
| 1644 | struct tcb *tcp; |
| 1645 | { |
| 1646 | return sys_kill(tcp); |
| 1647 | } |
| 1648 | |
| 1649 | int |
| 1650 | sys_sigpending(tcp) |
| 1651 | struct tcb *tcp; |
| 1652 | { |
| 1653 | sigset_t sigset; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1654 | |
| 1655 | if (exiting(tcp)) { |
| 1656 | if (syserror(tcp)) |
| 1657 | tprintf("%#lx", tcp->u_arg[0]); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1658 | else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1659 | tprintf("[?]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1660 | else |
Wichert Akkerman | 4695657 | 1999-11-26 10:12:59 +0000 | [diff] [blame] | 1661 | printsigmask(&sigset, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1662 | } |
| 1663 | return 0; |
| 1664 | } |
| 1665 | |
John Hughes | 4216208 | 2001-10-18 14:48:26 +0000 | [diff] [blame] | 1666 | int sys_sigwait(tcp) |
| 1667 | struct tcb *tcp; |
| 1668 | { |
| 1669 | sigset_t sigset; |
| 1670 | |
| 1671 | if (entering(tcp)) { |
| 1672 | if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0) |
| 1673 | tprintf("[?]"); |
| 1674 | else |
| 1675 | printsigmask(&sigset, 0); |
| 1676 | } |
| 1677 | else { |
| 1678 | if (!syserror(tcp)) { |
| 1679 | tcp->auxstr = signalent[tcp->u_rval]; |
| 1680 | return RVAL_DECIMAL | RVAL_STR; |
| 1681 | } |
| 1682 | } |
| 1683 | return 0; |
| 1684 | } |
| 1685 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1686 | #ifdef LINUX |
| 1687 | |
| 1688 | int |
| 1689 | sys_rt_sigprocmask(tcp) |
| 1690 | struct tcb *tcp; |
| 1691 | { |
| 1692 | sigset_t sigset; |
| 1693 | |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1694 | /* Note: arg[3] is the length of the sigset. */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1695 | if (entering(tcp)) { |
| 1696 | printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???"); |
| 1697 | tprintf(", "); |
| 1698 | if (!tcp->u_arg[1]) |
| 1699 | tprintf("NULL, "); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1700 | 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] | 1701 | tprintf("%#lx, ", tcp->u_arg[1]); |
| 1702 | else { |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1703 | printsigmask(&sigset, 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1704 | tprintf(", "); |
| 1705 | } |
| 1706 | } |
| 1707 | else { |
| 1708 | if (!tcp->u_arg[2]) |
| 1709 | |
| 1710 | tprintf("NULL"); |
| 1711 | else if (syserror(tcp)) |
| 1712 | tprintf("%#lx", tcp->u_arg[2]); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1713 | 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] | 1714 | tprintf("[?]"); |
| 1715 | else |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1716 | printsigmask(&sigset, 1); |
Nate Sammons | dab325a | 1999-03-29 23:33:35 +0000 | [diff] [blame] | 1717 | tprintf(", %lu", tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1718 | } |
| 1719 | return 0; |
| 1720 | } |
| 1721 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1722 | |
| 1723 | /* Structure describing the action to be taken when a signal arrives. */ |
| 1724 | struct new_sigaction |
| 1725 | { |
| 1726 | union |
| 1727 | { |
| 1728 | __sighandler_t __sa_handler; |
| 1729 | void (*__sa_sigaction) (int, siginfo_t *, void *); |
| 1730 | } |
| 1731 | __sigaction_handler; |
| 1732 | unsigned long sa_flags; |
| 1733 | void (*sa_restorer) (void); |
| 1734 | unsigned long int sa_mask[2]; |
| 1735 | }; |
| 1736 | |
| 1737 | |
| 1738 | int |
| 1739 | sys_rt_sigaction(tcp) |
| 1740 | struct tcb *tcp; |
| 1741 | { |
| 1742 | struct new_sigaction sa; |
| 1743 | sigset_t sigset; |
| 1744 | long addr; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1745 | |
| 1746 | if (entering(tcp)) { |
| 1747 | printsignal(tcp->u_arg[0]); |
| 1748 | tprintf(", "); |
| 1749 | addr = tcp->u_arg[1]; |
| 1750 | } else |
| 1751 | addr = tcp->u_arg[2]; |
| 1752 | if (addr == 0) |
| 1753 | tprintf("NULL"); |
| 1754 | else if (!verbose(tcp)) |
| 1755 | tprintf("%#lx", addr); |
| 1756 | else if (umove(tcp, addr, &sa) < 0) |
| 1757 | tprintf("{...}"); |
| 1758 | else { |
| 1759 | switch ((long) sa.__sigaction_handler.__sa_handler) { |
| 1760 | case (long) SIG_ERR: |
| 1761 | tprintf("{SIG_ERR}"); |
| 1762 | break; |
| 1763 | case (long) SIG_DFL: |
| 1764 | tprintf("{SIG_DFL}"); |
| 1765 | break; |
| 1766 | case (long) SIG_IGN: |
| 1767 | tprintf("{SIG_IGN}"); |
| 1768 | break; |
| 1769 | default: |
| 1770 | tprintf("{%#lx, ", |
| 1771 | (long) sa.__sigaction_handler.__sa_handler); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1772 | sigemptyset(&sigset); |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 1773 | #ifdef LINUXSPARC |
| 1774 | if (tcp->u_arg[4] <= sizeof(sigset)) |
| 1775 | memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]); |
| 1776 | #else |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1777 | if (tcp->u_arg[3] <= sizeof(sigset)) |
| 1778 | memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]); |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 1779 | #endif |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1780 | else |
| 1781 | memcpy(&sigset, &sa.sa_mask, sizeof(sigset)); |
| 1782 | printsigmask(&sigset, 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1783 | tprintf(", "); |
| 1784 | if (!printflags(sigact_flags, sa.sa_flags)) |
| 1785 | tprintf("0"); |
Roland McGrath | 2638cb4 | 2002-12-15 23:58:41 +0000 | [diff] [blame] | 1786 | #ifdef SA_RESTORER |
| 1787 | if (sa.sa_flags & SA_RESTORER) |
| 1788 | tprintf(", %p", sa.sa_restorer); |
| 1789 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1790 | tprintf("}"); |
| 1791 | } |
| 1792 | } |
| 1793 | if (entering(tcp)) |
| 1794 | tprintf(", "); |
| 1795 | else |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 1796 | #ifdef LINUXSPARC |
| 1797 | tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]); |
| 1798 | #elif defined(ALPHA) |
| 1799 | tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]); |
| 1800 | #else |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1801 | tprintf(", %lu", addr = tcp->u_arg[3]); |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 1802 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1803 | return 0; |
| 1804 | } |
| 1805 | |
| 1806 | int |
| 1807 | sys_rt_sigpending(tcp) |
| 1808 | struct tcb *tcp; |
| 1809 | { |
| 1810 | sigset_t sigset; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1811 | |
| 1812 | if (exiting(tcp)) { |
| 1813 | if (syserror(tcp)) |
| 1814 | tprintf("%#lx", tcp->u_arg[0]); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1815 | else if (copy_sigset_len(tcp, tcp->u_arg[0], |
| 1816 | &sigset, tcp->u_arg[1]) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1817 | tprintf("[?]"); |
| 1818 | else |
Wichert Akkerman | 4695657 | 1999-11-26 10:12:59 +0000 | [diff] [blame] | 1819 | printsigmask(&sigset, 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1820 | } |
| 1821 | return 0; |
| 1822 | } |
| 1823 | int |
| 1824 | sys_rt_sigsuspend(tcp) |
| 1825 | struct tcb *tcp; |
| 1826 | { |
| 1827 | if (entering(tcp)) { |
| 1828 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1829 | if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0) |
| 1830 | tprintf("[?]"); |
| 1831 | else |
| 1832 | printsigmask(&sigm, 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1833 | } |
| 1834 | return 0; |
| 1835 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1836 | int |
| 1837 | sys_rt_sigqueueinfo(tcp) |
| 1838 | struct tcb *tcp; |
| 1839 | { |
| 1840 | if (entering(tcp)) { |
| 1841 | siginfo_t si; |
| 1842 | tprintf("%lu, ", tcp->u_arg[0]); |
| 1843 | printsignal(tcp->u_arg[1]); |
| 1844 | tprintf(", "); |
| 1845 | if (umove(tcp, tcp->u_arg[2], &si) < 0) |
| 1846 | tprintf("%#lx", tcp->u_arg[2]); |
| 1847 | else |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 1848 | printsiginfo(&si, verbose (tcp)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1849 | } |
| 1850 | return 0; |
| 1851 | } |
| 1852 | |
| 1853 | int sys_rt_sigtimedwait(tcp) |
| 1854 | struct tcb *tcp; |
| 1855 | { |
| 1856 | if (entering(tcp)) { |
| 1857 | sigset_t sigset; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1858 | |
Roland McGrath | a39c5a1 | 2002-12-17 05:10:37 +0000 | [diff] [blame^] | 1859 | if (copy_sigset_len(tcp, tcp->u_arg[0], |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1860 | &sigset, tcp->u_arg[3]) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1861 | tprintf("[?]"); |
| 1862 | else |
Wichert Akkerman | 4695657 | 1999-11-26 10:12:59 +0000 | [diff] [blame] | 1863 | printsigmask(&sigset, 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1864 | tprintf(", "); |
| 1865 | } |
| 1866 | else { |
| 1867 | if (syserror(tcp)) |
| 1868 | tprintf("%#lx", tcp->u_arg[0]); |
| 1869 | else { |
| 1870 | siginfo_t si; |
| 1871 | if (umove(tcp, tcp->u_arg[1], &si) < 0) |
| 1872 | tprintf("%#lx", tcp->u_arg[1]); |
| 1873 | else |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 1874 | printsiginfo(&si, verbose (tcp)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1875 | /* XXX For now */ |
| 1876 | tprintf(", %#lx", tcp->u_arg[2]); |
| 1877 | tprintf(", %d", (int) tcp->u_arg[3]); |
| 1878 | } |
| 1879 | } |
| 1880 | return 0; |
| 1881 | }; |
| 1882 | |
| 1883 | #endif /* LINUX */ |