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