blob: 082f5c777c76596ef4485bc9dad65fecd899f85f [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
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 Akkerman4dc8a2a1999-12-23 14:20:14 +00005 * 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 Akkerman76baf7c1999-02-19 00:21:36 +00009 * 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 Akkerman76baf7c1999-02-19 00:21:36 +000038#include <signal.h>
39#include <sys/user.h>
40#include <fcntl.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000041
42#ifdef SVR4
43#include <sys/ucontext.h>
44#endif /* SVR4 */
45
Wichert Akkerman36915a11999-07-13 15:45:02 +000046#ifdef HAVE_SYS_REG_H
47# include <sys/reg.h>
Wichert Akkerman15dea971999-10-06 13:06:34 +000048#ifndef PTRACE_PEEKUSR
Wichert Akkerman36915a11999-07-13 15:45:02 +000049# define PTRACE_PEEKUSR PTRACE_PEEKUSER
Wichert Akkerman15dea971999-10-06 13:06:34 +000050#endif
51#ifndef PTRACE_POKEUSR
Wichert Akkerman36915a11999-07-13 15:45:02 +000052# define PTRACE_POKEUSR PTRACE_POKEUSER
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000053#endif
Wichert Akkermanfaf72222000-02-19 23:59:03 +000054#elif defined(HAVE_LINUX_PTRACE_H)
55#undef PTRACE_SYSCALL
56#include <linux/ptrace.h>
Wichert Akkerman15dea971999-10-06 13:06:34 +000057#endif
Wichert Akkerman36915a11999-07-13 15:45:02 +000058
Wichert Akkermanfaf72222000-02-19 23:59:03 +000059
Wichert Akkerman36915a11999-07-13 15:45:02 +000060#ifdef LINUX
61
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +000062#ifdef IA64
63# include <asm/ptrace_offsets.h>
64#endif /* !IA64 */
65
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000066#ifdef HAVE_ASM_SIGCONTEXT_H
67#include <asm/sigcontext.h>
68#ifdef SPARC
Wichert Akkerman9ce1a631999-08-29 23:15:07 +000069#include <asm/reg.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000070typedef struct {
Wichert Akkerman9ce1a631999-08-29 23:15:07 +000071 struct regs si_regs;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000072 int si_mask;
73} m_siginfo_t;
74#endif
75#else /* !HAVE_ASM_SIGCONTEXT_H */
76#ifdef I386
77struct 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 Akkerman2e2553a1999-05-09 00:29:58 +0000103struct sigcontext
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000104{
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
127char *signalent0[] = {
128#include "signalent.h"
129};
130int nsignals0 = sizeof signalent0 / sizeof signalent0[0];
131
132#if SUPPORTED_PERSONALITIES >= 2
133char *signalent1[] = {
134#include "signalent1.h"
135};
136int nsignals1 = sizeof signalent1 / sizeof signalent1[0];
137#endif /* SUPPORTED_PERSONALITIES >= 2 */
138
139#if SUPPORTED_PERSONALITIES >= 3
140char *signalent2[] = {
141#include "signalent2.h"
142};
143int nsignals2 = sizeof signalent2 / sizeof signalent2[0];
144#endif /* SUPPORTED_PERSONALITIES >= 3 */
145
146char **signalent;
147int nsignals;
148
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000149#if defined(SUNOS4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000150
151static 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
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000159#endif /* SUNOS4 || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000160
161#ifdef HAVE_SIGACTION
162
163static struct xlat sigact_flags[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000164#ifdef SA_RESTORER
165 { SA_RESTORER, "SA_RESTORER" },
166#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000167#ifdef SA_STACK
168 { SA_STACK, "SA_STACK" },
169#endif
170#ifdef SA_RESTART
171 { SA_RESTART, "SA_RESTART" },
172#endif
173#ifdef SA_INTERRUPT
174 { SA_INTERRUPT, "SA_INTERRUPT" },
175#endif
176#ifdef SA_NOMASK
177 { SA_NOMASK, "SA_NOMASK" },
178#endif
179#ifdef SA_ONESHOT
180 { SA_ONESHOT, "SA_ONESHOT" },
181#endif
182#ifdef SA_SIGINFO
183 { SA_SIGINFO, "SA_SIGINFO" },
184#endif
185#ifdef SA_RESETHAND
186 { SA_RESETHAND, "SA_RESETHAND" },
187#endif
188#ifdef SA_ONSTACK
189 { SA_ONSTACK, "SA_ONSTACK" },
190#endif
191#ifdef SA_NODEFER
192 { SA_NODEFER, "SA_NODEFER" },
193#endif
194#ifdef SA_NOCLDSTOP
195 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
196#endif
197#ifdef SA_NOCLDWAIT
198 { SA_NOCLDWAIT, "SA_NOCLDWAIT" },
199#endif
200#ifdef _SA_BSDCALL
201 { _SA_BSDCALL, "_SA_BSDCALL" },
202#endif
203 { 0, NULL },
204};
205
206static struct xlat sigprocmaskcmds[] = {
207 { SIG_BLOCK, "SIG_BLOCK" },
208 { SIG_UNBLOCK, "SIG_UNBLOCK" },
209 { SIG_SETMASK, "SIG_SETMASK" },
210#ifdef SIG_SETMASK32
211 { SIG_SETMASK32,"SIG_SETMASK32" },
212#endif
213 { 0, NULL },
214};
215
216#endif /* HAVE_SIGACTION */
217
Nate Sammonsce780fc1999-03-29 23:23:13 +0000218/* Anonymous realtime signals. */
219/* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a
220 constant. This is what we want. Otherwise, just use SIGRTMIN. */
221#ifdef SIGRTMIN
222#ifndef __SIGRTMIN
223#define __SIGRTMIN SIGRTMIN
224#define __SIGRTMAX SIGRTMAX /* likewise */
225#endif
226#endif
227
228char *
229signame(sig)
230int sig;
231{
232 static char buf[30];
233 if (sig < nsignals) {
234 return signalent[sig];
235#ifdef SIGRTMIN
Nate Sammons3080aa41999-03-30 00:16:41 +0000236 } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000237 sprintf(buf, "SIGRT_%ld", (long)(sig - __SIGRTMIN));
Nate Sammonsce780fc1999-03-29 23:23:13 +0000238 return buf;
239#endif /* SIGRTMIN */
240 } else {
241 sprintf(buf, "%d", sig);
242 return buf;
243 }
244}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000245
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000246#ifndef UNIXWARE
Nate Sammons4a121431999-04-06 01:19:39 +0000247static void
248long_to_sigset(l, s)
249long l;
250sigset_t *s;
251{
252 sigemptyset(s);
253 *(long *)s = l;
254}
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000255#endif
Nate Sammons4a121431999-04-06 01:19:39 +0000256
257static int
258copy_sigset_len(tcp, addr, s, len)
259struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000260long addr;
Nate Sammons4a121431999-04-06 01:19:39 +0000261sigset_t *s;
262int len;
263{
264 if (len > sizeof(*s))
265 len = sizeof(*s);
266 sigemptyset(s);
267 if (umoven(tcp, addr, len, (char *)s) < 0)
268 return -1;
269 return 0;
270}
271
272#ifdef LINUX
273/* Original sigset is unsigned long */
274#define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(long))
275#else
276#define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(sigset_t))
277#endif
278
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000279static char *
Nate Sammons4a121431999-04-06 01:19:39 +0000280sprintsigmask(s, mask, rt)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000281char *s;
282sigset_t *mask;
Nate Sammons4a121431999-04-06 01:19:39 +0000283int rt; /* set might include realtime sigs */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000284{
285 int i, nsigs;
Nate Sammons4a121431999-04-06 01:19:39 +0000286 int maxsigs;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000287 char *format;
288 static char outstr[256];
289
290 strcpy(outstr, s);
291 s = outstr + strlen(outstr);
292 nsigs = 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000293 maxsigs = nsignals;
294#ifdef __SIGRTMAX
295 if (rt)
296 maxsigs = __SIGRTMAX; /* instead */
297#endif
298 for (i = 1; i < maxsigs; i++) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000299 if (sigismember(mask, i) == 1)
300 nsigs++;
301 }
302 if (nsigs >= nsignals * 2 / 3) {
303 *s++ = '~';
Nate Sammons4a121431999-04-06 01:19:39 +0000304 for (i = 1; i < maxsigs; i++) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000305 switch (sigismember(mask, i)) {
306 case 1:
307 sigdelset(mask, i);
308 break;
309 case 0:
310 sigaddset(mask, i);
311 break;
312 }
313 }
314 }
315 format = "%s";
316 *s++ = '[';
Nate Sammons4a121431999-04-06 01:19:39 +0000317 for (i = 1; i < maxsigs; i++) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000318 if (sigismember(mask, i) == 1) {
John Hughesbdf48f52001-03-06 15:08:09 +0000319 /* real-time signals on solaris don't have
320 * signalent entries
321 */
322 if (i < nsignals) {
323 sprintf(s, format, signalent[i] + 3);
324 }
325 else {
326 char tsig[32];
327 sprintf(tsig, "%u", i);
328 sprintf(s, format, tsig);
329 }
330 s += strlen(s);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000331 format = " %s";
332 }
333 }
334 *s++ = ']';
335 *s = '\0';
336 return outstr;
337}
338
339static void
Nate Sammons4a121431999-04-06 01:19:39 +0000340printsigmask(mask, rt)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000341sigset_t *mask;
Nate Sammons4a121431999-04-06 01:19:39 +0000342int rt;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000343{
Nate Sammons4a121431999-04-06 01:19:39 +0000344 tprintf("%s", sprintsigmask("", mask, rt));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000345}
346
347void
348printsignal(nr)
349int nr;
350{
Nate Sammonsce780fc1999-03-29 23:23:13 +0000351 tprintf(signame(nr));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000352}
353
354/*
355 * Check process TCP for the disposition of signal SIG.
356 * Return 1 if the process would somehow manage to survive signal SIG,
357 * else return 0. This routine will never be called with SIGKILL.
358 */
359int
360sigishandled(tcp, sig)
361struct tcb *tcp;
362int sig;
363{
364#ifdef LINUX
365 int sfd;
366 char sname[32];
367 char buf[1024];
368 char *s;
369 int i;
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000370 unsigned int signalled, blocked, ignored, caught;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000371
372 /* This is incredibly costly but it's worth it. */
373 sprintf(sname, "/proc/%d/stat", tcp->pid);
374 if ((sfd = open(sname, O_RDONLY)) == -1) {
375 perror(sname);
376 return 1;
377 }
378 i = read(sfd, buf, 1024);
379 buf[i] = '\0';
380 close(sfd);
381 /*
382 * Skip the extraneous fields. This loses if the
383 * command name has any spaces in it. So be it.
384 */
385 for (i = 0, s = buf; i < 30; i++) {
386 while (*++s != ' ') {
387 if (!*s)
388 break;
389 }
390 }
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000391 if (sscanf(s, "%u%u%u%u",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000392 &signalled, &blocked, &ignored, &caught) != 4) {
393 fprintf(stderr, "/proc/pid/stat format error\n");
394 return 1;
395 }
396#ifdef DEBUG
397 fprintf(stderr, "sigs: %08x %08x %08x %08x\n",
398 signalled, blocked, ignored, caught);
399#endif
400 if ((ignored & sigmask(sig)) || (caught & sigmask(sig)))
401 return 1;
402#endif /* LINUX */
403
404#ifdef SUNOS4
405 void (*u_signal)();
406
407 if (upeek(tcp->pid, uoff(u_signal[0]) + sig*sizeof(u_signal),
408 (long *) &u_signal) < 0) {
409 return 0;
410 }
411 if (u_signal != SIG_DFL)
412 return 1;
413#endif /* SUNOS4 */
414
415#ifdef SVR4
416 /*
417 * Since procfs doesn't interfere with wait I think it is safe
418 * to punt on this question. If not, the information is there.
419 */
420 return 1;
421#else /* !SVR4 */
422 switch (sig) {
423 case SIGCONT:
424 case SIGSTOP:
425 case SIGTSTP:
426 case SIGTTIN:
427 case SIGTTOU:
428 case SIGCHLD:
429 case SIGIO:
430#if defined(SIGURG) && SIGURG != SIGIO
431 case SIGURG:
432#endif
433 case SIGWINCH:
434 /* Gloria Gaynor says ... */
435 return 1;
436 default:
437 break;
438 }
439 return 0;
440#endif /* !SVR4 */
441}
442
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000443#if defined(SUNOS4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000444
445int
446sys_sigvec(tcp)
447struct tcb *tcp;
448{
449 struct sigvec sv;
450 long addr;
451
452 if (entering(tcp)) {
453 printsignal(tcp->u_arg[0]);
454 tprintf(", ");
455 addr = tcp->u_arg[1];
456 } else {
457 addr = tcp->u_arg[2];
458 }
459 if (addr == 0)
460 tprintf("NULL");
461 else if (!verbose(tcp))
462 tprintf("%#lx", addr);
463 else if (umove(tcp, addr, &sv) < 0)
464 tprintf("{...}");
465 else {
466 switch ((int) sv.sv_handler) {
467 case (int) SIG_ERR:
468 tprintf("{SIG_ERR}");
469 break;
470 case (int) SIG_DFL:
471 tprintf("{SIG_DFL}");
472 break;
473 case (int) SIG_IGN:
474 if (tcp->u_arg[0] == SIGTRAP) {
475 tcp->flags |= TCB_SIGTRAPPED;
476 kill(tcp->pid, SIGSTOP);
477 }
478 tprintf("{SIG_IGN}");
479 break;
480 case (int) SIG_HOLD:
481 if (tcp->u_arg[0] == SIGTRAP) {
482 tcp->flags |= TCB_SIGTRAPPED;
483 kill(tcp->pid, SIGSTOP);
484 }
485 tprintf("SIG_HOLD");
486 break;
487 default:
488 if (tcp->u_arg[0] == SIGTRAP) {
489 tcp->flags |= TCB_SIGTRAPPED;
490 kill(tcp->pid, SIGSTOP);
491 }
492 tprintf("{%#lx, ", (unsigned long) sv.sv_handler);
Nate Sammons4a121431999-04-06 01:19:39 +0000493 printsigmask(&sv.sv_mask, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000494 tprintf(", ");
495 if (!printflags(sigvec_flags, sv.sv_flags))
496 tprintf("0");
497 tprintf("}");
498 }
499 }
500 if (entering(tcp))
501 tprintf(", ");
502 return 0;
503}
504
505int
506sys_sigpause(tcp)
507struct tcb *tcp;
508{
509 if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */
Nate Sammons4a121431999-04-06 01:19:39 +0000510 sigset_t sigm;
511 long_to_sigset(tcp->u_arg[0], &sigm);
512 printsigmask(&sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000513 }
514 return 0;
515}
516
517int
518sys_sigstack(tcp)
519struct tcb *tcp;
520{
521 struct sigstack ss;
522 long addr;
523
524 if (entering(tcp))
525 addr = tcp->u_arg[0];
526 else
527 addr = tcp->u_arg[1];
528 if (addr == 0)
529 tprintf("NULL");
530 else if (umove(tcp, addr, &ss) < 0)
531 tprintf("%#lx", addr);
532 else {
533 tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp);
534 tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO");
535 }
536 if (entering(tcp))
537 tprintf(", ");
538 return 0;
539}
540
541int
542sys_sigcleanup(tcp)
543struct tcb *tcp;
544{
545 return 0;
546}
547
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000548#endif /* SUNOS4 || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000549
550#ifndef SVR4
551
552int
553sys_sigsetmask(tcp)
554struct tcb *tcp;
555{
556 if (entering(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000557 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000558 long_to_sigset(tcp->u_arg[0], &sigm);
559 printsigmask(&sigm, 0);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000560#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000561 if ((tcp->u_arg[0] & sigmask(SIGTRAP))) {
562 /* Mark attempt to block SIGTRAP */
563 tcp->flags |= TCB_SIGTRAPPED;
564 /* Send unblockable signal */
565 kill(tcp->pid, SIGSTOP);
566 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000567#endif /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000568 }
569 else if (!syserror(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000570 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000571 long_to_sigset(tcp->u_rval, &sigm);
572 tcp->auxstr = sprintsigmask("old mask ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000573
574 return RVAL_HEX | RVAL_STR;
575 }
576 return 0;
577}
578
579int
580sys_sigblock(tcp)
581struct tcb *tcp;
582{
583 return sys_sigsetmask(tcp);
584}
585
586#endif /* !SVR4 */
587
588#ifdef HAVE_SIGACTION
589
590#ifdef LINUX
591struct old_sigaction {
592 __sighandler_t __sa_handler;
593 unsigned long sa_mask;
594 unsigned long sa_flags;
595 void (*sa_restorer)(void);
596};
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000597#define SA_HANDLER __sa_handler
598#endif /* LINUX */
599
600#ifndef SA_HANDLER
601#define SA_HANDLER sa_handler
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000602#endif
603
604int
605sys_sigaction(tcp)
606struct tcb *tcp;
607{
608 long addr;
Nate Sammons4a121431999-04-06 01:19:39 +0000609#ifdef LINUX
John Hughes1e4cb342001-03-06 09:25:46 +0000610 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000611 struct old_sigaction sa;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000612#else
613 struct sigaction sa;
614#endif
615
616
617 if (entering(tcp)) {
618 printsignal(tcp->u_arg[0]);
619 tprintf(", ");
620 addr = tcp->u_arg[1];
621 } else
622 addr = tcp->u_arg[2];
623 if (addr == 0)
624 tprintf("NULL");
625 else if (!verbose(tcp))
626 tprintf("%#lx", addr);
627 else if (umove(tcp, addr, &sa) < 0)
628 tprintf("{...}");
629 else {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000630 switch ((long) sa.SA_HANDLER) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000631 case (long) SIG_ERR:
632 tprintf("{SIG_ERR}");
633 break;
634 case (long) SIG_DFL:
635 tprintf("{SIG_DFL}");
636 break;
637 case (long) SIG_IGN:
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000638#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000639 if (tcp->u_arg[0] == SIGTRAP) {
640 tcp->flags |= TCB_SIGTRAPPED;
641 kill(tcp->pid, SIGSTOP);
642 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000643#endif /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000644 tprintf("{SIG_IGN}");
645 break;
646 default:
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000647#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000648 if (tcp->u_arg[0] == SIGTRAP) {
649 tcp->flags |= TCB_SIGTRAPPED;
650 kill(tcp->pid, SIGSTOP);
651 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000652#endif /* !USE_PROCFS */
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000653 tprintf("{%#lx, ", (long) sa.SA_HANDLER);
Wichert Akkerman48214be1999-11-26 09:55:42 +0000654#ifndef LINUX
655 printsigmask (&sa.sa_mask, 0);
656#else
Nate Sammons4a121431999-04-06 01:19:39 +0000657 long_to_sigset(sa.sa_mask, &sigset);
658 printsigmask(&sigset, 0);
Wichert Akkerman48214be1999-11-26 09:55:42 +0000659#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000660 tprintf(", ");
661 if (!printflags(sigact_flags, sa.sa_flags))
662 tprintf("0");
663 tprintf("}");
664 }
665 }
666 if (entering(tcp))
667 tprintf(", ");
668#ifdef LINUX
669 else
670 tprintf(", %#lx", (unsigned long) sa.sa_restorer);
671#endif
672 return 0;
673}
674
675int
676sys_signal(tcp)
677struct tcb *tcp;
678{
679 if (entering(tcp)) {
680 printsignal(tcp->u_arg[0]);
Wichert Akkerman16a03d22000-08-10 02:14:04 +0000681 tprintf(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000682 switch (tcp->u_arg[1]) {
683 case (int) SIG_ERR:
684 tprintf("SIG_ERR");
685 break;
686 case (int) SIG_DFL:
687 tprintf("SIG_DFL");
688 break;
689 case (int) SIG_IGN:
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000690#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000691 if (tcp->u_arg[0] == SIGTRAP) {
692 tcp->flags |= TCB_SIGTRAPPED;
693 kill(tcp->pid, SIGSTOP);
694 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000695#endif /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000696 tprintf("SIG_IGN");
697 break;
698 default:
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000699#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000700 if (tcp->u_arg[0] == SIGTRAP) {
701 tcp->flags |= TCB_SIGTRAPPED;
702 kill(tcp->pid, SIGSTOP);
703 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000704#endif /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000705 tprintf("%#lx", tcp->u_arg[1]);
706 }
Wichert Akkerman16a03d22000-08-10 02:14:04 +0000707 return 0;
708 }
709 else {
710 switch (tcp->u_rval) {
711 case (int) SIG_ERR:
712 tcp->auxstr = "SIG_ERR"; break;
713 case (int) SIG_DFL:
714 tcp->auxstr = "SIG_DFL"; break;
715 case (int) SIG_IGN:
716 tcp->auxstr = "SIG_IGN"; break;
717 default:
718 tcp->auxstr = NULL;
719 }
720 return RVAL_HEX | RVAL_STR;
721 }
722}
723
724int
725sys_sighold(tcp)
726struct tcb *tcp;
727{
728 if (entering(tcp)) {
729 printsignal(tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000730 }
731 return 0;
732}
733
734#endif /* HAVE_SIGACTION */
735
736#ifdef LINUX
737
738int
739sys_sigreturn(tcp)
740struct tcb *tcp;
741{
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000742#ifdef S390
743 long usp;
744 struct sigcontext_struct sc;
745
746 if (entering(tcp)) {
747 tcp->u_arg[0] = 0;
748 if (upeek(tcp->pid,PT_GPR15,&usp)<0)
749 return 0;
750 if (umove(tcp, usp+__SIGNAL_FRAMESIZE, &sc) < 0)
751 return 0;
752 tcp->u_arg[0] = 1;
753 memcpy(&tcp->u_arg[1],&sc.oldmask[0],sizeof(sigset_t));
754 } else {
755 tcp->u_rval = tcp->u_error = 0;
756 if (tcp->u_arg[0] == 0)
757 return 0;
758 tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1]);
759 return RVAL_NONE | RVAL_STR;
760 }
761 return 0;
762#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000763#ifdef I386
764 long esp;
765 struct sigcontext_struct sc;
766
767 if (entering(tcp)) {
768 tcp->u_arg[0] = 0;
769 if (upeek(tcp->pid, 4*UESP, &esp) < 0)
770 return 0;
771 if (umove(tcp, esp, &sc) < 0)
772 return 0;
773 tcp->u_arg[0] = 1;
774 tcp->u_arg[1] = sc.oldmask;
775 }
776 else {
777 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000778 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000779 tcp->u_rval = tcp->u_error = 0;
780 if (tcp->u_arg[0] == 0)
781 return 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000782 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000783 return RVAL_NONE | RVAL_STR;
784 }
785 return 0;
786#else /* !I386 */
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000787#ifdef IA64
788 struct sigcontext sc;
789 long sp;
790
791 if (entering(tcp)) {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000792 /* offset of sigcontext in the kernel's sigframe structure: */
793# define SIGFRAME_SC_OFFSET 0x90
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000794 tcp->u_arg[0] = 0;
795 if (upeek(tcp->pid, PT_R12, &sp) < 0)
796 return 0;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000797 if (umove(tcp, sp + 16 + SIGFRAME_SC_OFFSET, &sc) < 0)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000798 return 0;
799 tcp->u_arg[0] = 1;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000800 memcpy(tcp->u_arg + 1, &sc.sc_mask, sizeof(sc.sc_mask));
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000801 }
802 else {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000803 sigset_t sigm;
804
805 memcpy(&sigm, tcp->u_arg + 1, sizeof (sigm));
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000806 tcp->u_rval = tcp->u_error = 0;
807 if (tcp->u_arg[0] == 0)
808 return 0;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000809 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000810 return RVAL_NONE | RVAL_STR;
811 }
812 return 0;
813#else /* !IA64 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000814#ifdef POWERPC
815 long esp;
816 struct sigcontext_struct sc;
817
818 if (entering(tcp)) {
819 tcp->u_arg[0] = 0;
820 if (upeek(tcp->pid, 4*PT_R1, &esp) < 0)
821 return 0;
822 if (umove(tcp, esp, &sc) < 0)
823 return 0;
824 tcp->u_arg[0] = 1;
825 tcp->u_arg[1] = sc.oldmask;
826 }
827 else {
828 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000829 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000830 tcp->u_rval = tcp->u_error = 0;
831 if (tcp->u_arg[0] == 0)
832 return 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000833 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000834 return RVAL_NONE | RVAL_STR;
835 }
836 return 0;
837#else /* !POWERPC */
838#ifdef M68K
839 long usp;
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000840 struct sigcontext sc;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000841
842 if (entering(tcp)) {
843 tcp->u_arg[0] = 0;
844 if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
845 return 0;
846 if (umove(tcp, usp, &sc) < 0)
847 return 0;
848 tcp->u_arg[0] = 1;
849 tcp->u_arg[1] = sc.sc_mask;
850 }
851 else {
852 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000853 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000854 tcp->u_rval = tcp->u_error = 0;
855 if (tcp->u_arg[0] == 0)
856 return 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000857 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000858 return RVAL_NONE | RVAL_STR;
859 }
860 return 0;
861#else /* !M68K */
862#ifdef ALPHA
863 long fp;
864 struct sigcontext_struct sc;
865
866 if (entering(tcp)) {
867 tcp->u_arg[0] = 0;
868 if (upeek(tcp->pid, REG_FP, &fp) < 0)
869 return 0;
870 if (umove(tcp, fp, &sc) < 0)
871 return 0;
872 tcp->u_arg[0] = 1;
873 tcp->u_arg[1] = sc.sc_mask;
874 }
875 else {
876 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000877 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000878 tcp->u_rval = tcp->u_error = 0;
879 if (tcp->u_arg[0] == 0)
880 return 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000881 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000882 return RVAL_NONE | RVAL_STR;
883 }
884 return 0;
885#else
886#ifdef SPARC
887 long i1;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000888 struct regs regs;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000889 m_siginfo_t si;
890
891 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)&regs, 0) < 0) {
892 perror("sigreturn: PTRACE_GETREGS ");
893 return 0;
894 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000895 if(entering(tcp)) {
896 tcp->u_arg[0] = 0;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000897 i1 = regs.r_o1;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000898 if(umove(tcp, i1, &si) < 0) {
899 perror("sigreturn: umove ");
900 return 0;
901 }
902 tcp->u_arg[0] = 1;
903 tcp->u_arg[1] = si.si_mask;
904 } else {
905 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000906 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000907 tcp->u_rval = tcp->u_error = 0;
908 if(tcp->u_arg[0] == 0)
909 return 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000910 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000911 return RVAL_NONE | RVAL_STR;
912 }
913 return 0;
Wichert Akkermanf90da011999-10-31 21:15:38 +0000914#else
915#ifdef MIPS
916 long sp;
917 struct sigcontext sc;
918
919 if(entering(tcp)) {
920 tcp->u_arg[0] = 0;
921 if (upeek(tcp->pid, REG_SP, &sp) < 0)
922 return 0;
923 if (umove(tcp, sp, &sc) < 0)
924 return 0;
925 tcp->u_arg[0] = 1;
926 tcp->u_arg[1] = sc.sc_sigset;
927 } else {
928 tcp->u_rval = tcp->u_error = 0;
929 if(tcp->u_arg[0] == 0)
930 return 0;
931 tcp->auxstr = sprintsigmask("mask now ", tcp->u_arg[1]);
932 return RVAL_NONE | RVAL_STR;
933 }
934 return 0;
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000935#else
936#ifdef HPPA
937#warning NO sys_sigreturn DECODE FOR HPPA
938 return 0;
939#endif /* HPPA */
Wichert Akkermanf90da011999-10-31 21:15:38 +0000940#endif /* MIPS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000941#endif /* SPARC */
942#endif /* ALPHA */
943#endif /* !M68K */
944#endif /* !POWERPC */
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000945#endif /* !IA64 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000946#endif /* !I386 */
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000947#endif /* S390 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000948}
949
950int
951sys_siggetmask(tcp)
952struct tcb *tcp;
953{
954 if (exiting(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000955 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000956 long_to_sigset(tcp->u_rval, &sigm);
957 tcp->auxstr = sprintsigmask("mask ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000958 }
959 return RVAL_HEX | RVAL_STR;
960}
961
962int
963sys_sigsuspend(tcp)
964struct tcb *tcp;
965{
966 if (entering(tcp)) {
967 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000968 long_to_sigset(tcp->u_arg[2], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000969#if 0
970 /* first two are not really arguments, but print them anyway */
971 /* nevermind, they are an anachronism now, too bad... */
972 tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
973#endif
Nate Sammons4a121431999-04-06 01:19:39 +0000974 printsigmask(&sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000975 }
976 return 0;
977}
978
979#endif /* LINUX */
980
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000981#if defined(SVR4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000982
983int
984sys_sigsuspend(tcp)
985struct tcb *tcp;
986{
987 sigset_t sigset;
988
989 if (entering(tcp)) {
990 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
991 tprintf("[?]");
992 else
Wichert Akkerman46956571999-11-26 10:12:59 +0000993 printsigmask(&sigset, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000994 }
995 return 0;
996}
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000997#ifndef FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000998static struct xlat ucontext_flags[] = {
999 { UC_SIGMASK, "UC_SIGMASK" },
1000 { UC_STACK, "UC_STACK" },
1001 { UC_CPU, "UC_CPU" },
1002#ifdef UC_FPU
1003 { UC_FPU, "UC_FPU" },
1004#endif
1005#ifdef UC_INTR
1006 { UC_INTR, "UC_INTR" },
1007#endif
1008 { 0, NULL },
1009};
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001010#endif /* !FREEBSD */
1011#endif /* SVR4 || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001012
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001013#if defined SVR4 || defined LINUX || defined FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001014#if defined LINUX && !defined SS_ONSTACK
1015#define SS_ONSTACK 1
1016#define SS_DISABLE 2
1017#if __GLIBC_MINOR__ == 0
1018typedef struct
1019{
1020 __ptr_t ss_sp;
1021 int ss_flags;
1022 size_t ss_size;
1023} stack_t;
1024#endif
1025#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001026#ifdef FREEBSD
1027#define stack_t struct sigaltstack
1028#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001029
1030static struct xlat sigaltstack_flags[] = {
1031 { SS_ONSTACK, "SS_ONSTACK" },
1032 { SS_DISABLE, "SS_DISABLE" },
1033 { 0, NULL },
1034};
1035#endif
1036
1037#ifdef SVR4
1038static void
1039printcontext(tcp, ucp)
1040struct tcb *tcp;
1041ucontext_t *ucp;
1042{
1043 tprintf("{");
1044 if (!abbrev(tcp)) {
1045 tprintf("uc_flags=");
1046 if (!printflags(ucontext_flags, ucp->uc_flags))
1047 tprintf("0");
1048 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
1049 }
1050 tprintf("uc_sigmask=");
Nate Sammons4a121431999-04-06 01:19:39 +00001051 printsigmask(ucp->uc_sigmask, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001052 if (!abbrev(tcp)) {
1053 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
1054 (unsigned long) ucp->uc_stack.ss_sp,
1055 ucp->uc_stack.ss_size);
1056 if (!printflags(sigaltstack_flags, ucp->uc_stack.ss_flags))
1057 tprintf("0");
1058 tprintf("}");
1059 }
1060 tprintf(", ...}");
1061}
1062
1063int
1064sys_getcontext(tcp)
1065struct tcb *tcp;
1066{
1067 ucontext_t uc;
1068
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001069 if (exiting(tcp)) {
1070 if (tcp->u_error)
1071 tprintf("%#lx", tcp->u_arg[0]);
1072 else if (!tcp->u_arg[0])
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001073 tprintf("NULL");
1074 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1075 tprintf("{...}");
1076 else
1077 printcontext(tcp, &uc);
1078 }
1079 return 0;
1080}
1081
1082int
1083sys_setcontext(tcp)
1084struct tcb *tcp;
1085{
1086 ucontext_t uc;
1087
1088 if (entering(tcp)) {
1089 if (!tcp->u_arg[0])
1090 tprintf("NULL");
1091 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1092 tprintf("{...}");
1093 else
1094 printcontext(tcp, &uc);
1095 }
1096 else {
1097 tcp->u_rval = tcp->u_error = 0;
1098 if (tcp->u_arg[0] == 0)
1099 return 0;
1100 return RVAL_NONE;
1101 }
1102 return 0;
1103}
1104
1105#endif /* SVR4 */
1106
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001107#if defined(LINUX) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001108
1109static int
1110print_stack_t(tcp, addr)
1111struct tcb *tcp;
1112unsigned long addr;
1113{
1114 stack_t ss;
1115 if (umove(tcp, addr, &ss) < 0)
1116 return -1;
1117 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
1118 if (!printflags(sigaltstack_flags, ss.ss_flags))
1119 tprintf("0");
1120 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
1121 return 0;
1122}
1123
1124int
1125sys_sigaltstack(tcp)
1126 struct tcb *tcp;
1127{
1128 if (entering(tcp)) {
1129 if (tcp->u_arg[0] == 0)
1130 tprintf("NULL");
1131 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
1132 return -1;
1133 }
1134 else {
1135 tprintf(", ");
1136 if (tcp->u_arg[1] == 0)
1137 tprintf("NULL");
1138 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
1139 return -1;
1140 }
1141 return 0;
1142}
1143#endif
1144
1145#ifdef HAVE_SIGACTION
1146
1147int
1148sys_sigprocmask(tcp)
1149struct tcb *tcp;
1150{
1151#ifdef ALPHA
1152 if (entering(tcp)) {
1153 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1154 tprintf(", ");
Nate Sammons4a121431999-04-06 01:19:39 +00001155 printsigmask(tcp->u_arg[1], 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001156 }
1157 else if (!syserror(tcp)) {
Nate Sammons4a121431999-04-06 01:19:39 +00001158 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001159 return RVAL_HEX | RVAL_STR;
1160 }
1161#else /* !ALPHA */
1162 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001163
1164 if (entering(tcp)) {
1165#ifdef SVR4
1166 if (tcp->u_arg[0] == 0)
1167 tprintf("0");
1168 else
1169#endif /* SVR4 */
1170 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1171 tprintf(", ");
1172 if (!tcp->u_arg[1])
1173 tprintf("NULL, ");
Nate Sammons4a121431999-04-06 01:19:39 +00001174 else if (copy_sigset(tcp, tcp->u_arg[1], &sigset) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001175 tprintf("%#lx, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001176 else {
Nate Sammons4a121431999-04-06 01:19:39 +00001177 printsigmask(&sigset, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001178 tprintf(", ");
1179 }
1180 }
1181 else {
1182 if (!tcp->u_arg[2])
1183 tprintf("NULL");
1184 else if (syserror(tcp))
1185 tprintf("%#lx", tcp->u_arg[2]);
Nate Sammons4a121431999-04-06 01:19:39 +00001186 else if (copy_sigset(tcp, tcp->u_arg[2], &sigset) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001187 tprintf("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001188 else
Nate Sammons4a121431999-04-06 01:19:39 +00001189 printsigmask(&sigset, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001190 }
1191#endif /* !ALPHA */
1192 return 0;
1193}
1194
1195#endif /* HAVE_SIGACTION */
1196
1197int
1198sys_kill(tcp)
1199struct tcb *tcp;
1200{
1201 if (entering(tcp)) {
Nate Sammonsce780fc1999-03-29 23:23:13 +00001202 tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001203 }
1204 return 0;
1205}
1206
1207int
1208sys_killpg(tcp)
1209struct tcb *tcp;
1210{
1211 return sys_kill(tcp);
1212}
1213
1214int
1215sys_sigpending(tcp)
1216struct tcb *tcp;
1217{
1218 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001219
1220 if (exiting(tcp)) {
1221 if (syserror(tcp))
1222 tprintf("%#lx", tcp->u_arg[0]);
Nate Sammons4a121431999-04-06 01:19:39 +00001223 else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001224 tprintf("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001225 else
Wichert Akkerman46956571999-11-26 10:12:59 +00001226 printsigmask(&sigset, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001227 }
1228 return 0;
1229}
1230
1231#ifdef LINUX
1232
1233 int
1234sys_rt_sigprocmask(tcp)
1235 struct tcb *tcp;
1236{
1237 sigset_t sigset;
1238
Nate Sammons4a121431999-04-06 01:19:39 +00001239 /* Note: arg[3] is the length of the sigset. */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001240 if (entering(tcp)) {
1241 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1242 tprintf(", ");
1243 if (!tcp->u_arg[1])
1244 tprintf("NULL, ");
Nate Sammons4a121431999-04-06 01:19:39 +00001245 else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001246 tprintf("%#lx, ", tcp->u_arg[1]);
1247 else {
Nate Sammons4a121431999-04-06 01:19:39 +00001248 printsigmask(&sigset, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001249 tprintf(", ");
1250 }
1251 }
1252 else {
1253 if (!tcp->u_arg[2])
1254
1255 tprintf("NULL");
1256 else if (syserror(tcp))
1257 tprintf("%#lx", tcp->u_arg[2]);
Nate Sammons4a121431999-04-06 01:19:39 +00001258 else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001259 tprintf("[?]");
1260 else
Nate Sammons4a121431999-04-06 01:19:39 +00001261 printsigmask(&sigset, 1);
Nate Sammonsdab325a1999-03-29 23:33:35 +00001262 tprintf(", %lu", tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001263 }
1264 return 0;
1265}
1266
1267#if __GLIBC_MINOR__ < 1
1268/* Type for data associated with a signal. */
1269typedef union sigval
1270{
1271 int sival_int;
1272 void *sival_ptr;
1273} sigval_t;
1274
1275# define __SI_MAX_SIZE 128
1276# define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
1277
1278typedef struct siginfo
1279{
1280 int si_signo; /* Signal number. */
1281 int si_errno; /* If non-zero, an errno value associated with
1282 this signal, as defined in <errno.h>. */
1283 int si_code; /* Signal code. */
1284
1285 union
1286 {
1287 int _pad[__SI_PAD_SIZE];
1288
1289 /* kill(). */
1290 struct
1291 {
1292 __pid_t si_pid; /* Sending process ID. */
1293 __uid_t si_uid; /* Real user ID of sending process. */
1294 } _kill;
1295
1296 /* POSIX.1b timers. */
1297 struct
1298 {
1299 unsigned int _timer1;
1300 unsigned int _timer2;
1301 } _timer;
1302
1303 /* POSIX.1b signals. */
1304 struct
1305 {
1306 __pid_t si_pid; /* Sending process ID. */
1307 __uid_t si_uid; /* Real user ID of sending process. */
1308 sigval_t si_sigval; /* Signal value. */
1309 } _rt;
1310
1311 /* SIGCHLD. */
1312 struct
1313 {
1314 __pid_t si_pid; /* Which child. */
1315 int si_status; /* Exit value or signal. */
1316 __clock_t si_utime;
1317 __clock_t si_stime;
1318 } _sigchld;
1319
1320 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
1321 struct
1322 {
1323 void *si_addr; /* Faulting insn/memory ref. */
1324 } _sigfault;
1325
1326 /* SIGPOLL. */
1327 struct
1328 {
1329 int si_band; /* Band event for SIGPOLL. */
1330 int si_fd;
1331 } _sigpoll;
1332 } _sifields;
1333} siginfo_t;
1334#endif
1335
1336/* Structure describing the action to be taken when a signal arrives. */
1337struct new_sigaction
1338{
1339 union
1340 {
1341 __sighandler_t __sa_handler;
1342 void (*__sa_sigaction) (int, siginfo_t *, void *);
1343 }
1344 __sigaction_handler;
1345 unsigned long sa_flags;
1346 void (*sa_restorer) (void);
1347 unsigned long int sa_mask[2];
1348};
1349
1350
1351 int
1352sys_rt_sigaction(tcp)
1353 struct tcb *tcp;
1354{
1355 struct new_sigaction sa;
1356 sigset_t sigset;
1357 long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001358
1359 if (entering(tcp)) {
1360 printsignal(tcp->u_arg[0]);
1361 tprintf(", ");
1362 addr = tcp->u_arg[1];
1363 } else
1364 addr = tcp->u_arg[2];
1365 if (addr == 0)
1366 tprintf("NULL");
1367 else if (!verbose(tcp))
1368 tprintf("%#lx", addr);
1369 else if (umove(tcp, addr, &sa) < 0)
1370 tprintf("{...}");
1371 else {
1372 switch ((long) sa.__sigaction_handler.__sa_handler) {
1373 case (long) SIG_ERR:
1374 tprintf("{SIG_ERR}");
1375 break;
1376 case (long) SIG_DFL:
1377 tprintf("{SIG_DFL}");
1378 break;
1379 case (long) SIG_IGN:
1380 tprintf("{SIG_IGN}");
1381 break;
1382 default:
1383 tprintf("{%#lx, ",
1384 (long) sa.__sigaction_handler.__sa_handler);
Nate Sammons4a121431999-04-06 01:19:39 +00001385 sigemptyset(&sigset);
Wichert Akkermandacfb6e1999-06-03 14:21:07 +00001386#ifdef LINUXSPARC
1387 if (tcp->u_arg[4] <= sizeof(sigset))
1388 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
1389#else
Nate Sammons4a121431999-04-06 01:19:39 +00001390 if (tcp->u_arg[3] <= sizeof(sigset))
1391 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
Wichert Akkermandacfb6e1999-06-03 14:21:07 +00001392#endif
Nate Sammons4a121431999-04-06 01:19:39 +00001393 else
1394 memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
1395 printsigmask(&sigset, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001396 tprintf(", ");
1397 if (!printflags(sigact_flags, sa.sa_flags))
1398 tprintf("0");
1399 tprintf("}");
1400 }
1401 }
1402 if (entering(tcp))
1403 tprintf(", ");
1404 else
Wichert Akkermandacfb6e1999-06-03 14:21:07 +00001405#ifdef LINUXSPARC
1406 tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
1407#elif defined(ALPHA)
1408 tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
1409#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001410 tprintf(", %lu", addr = tcp->u_arg[3]);
Wichert Akkermandacfb6e1999-06-03 14:21:07 +00001411#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001412 return 0;
1413}
1414
1415 int
1416sys_rt_sigpending(tcp)
1417 struct tcb *tcp;
1418{
1419 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001420
1421 if (exiting(tcp)) {
1422 if (syserror(tcp))
1423 tprintf("%#lx", tcp->u_arg[0]);
Nate Sammons4a121431999-04-06 01:19:39 +00001424 else if (copy_sigset_len(tcp, tcp->u_arg[0],
1425 &sigset, tcp->u_arg[1]) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001426 tprintf("[?]");
1427 else
Wichert Akkerman46956571999-11-26 10:12:59 +00001428 printsigmask(&sigset, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001429 }
1430 return 0;
1431}
1432 int
1433sys_rt_sigsuspend(tcp)
1434 struct tcb *tcp;
1435{
1436 if (entering(tcp)) {
1437 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +00001438 if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0)
1439 tprintf("[?]");
1440 else
1441 printsigmask(&sigm, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001442 }
1443 return 0;
1444}
1445#ifndef ILL_ILLOPC
1446#define ILL_ILLOPC 1 /* illegal opcode */
1447#define ILL_ILLOPN 2 /* illegal operand */
1448#define ILL_ILLADR 3 /* illegal addressing mode */
1449#define ILL_ILLTRP 4 /* illegal trap */
1450#define ILL_PRVOPC 5 /* privileged opcode */
1451#define ILL_PRVREG 6 /* privileged register */
1452#define ILL_COPROC 7 /* coprocessor error */
1453#define ILL_BADSTK 8 /* internal stack error */
1454#define FPE_INTDIV 1 /* integer divide by zero */
1455#define FPE_INTOVF 2 /* integer overflow */
1456#define FPE_FLTDIV 3 /* floating point divide by zero */
1457#define FPE_FLTOVF 4 /* floating point overflow */
1458#define FPE_FLTUND 5 /* floating point underflow */
1459#define FPE_FLTRES 6 /* floating point inexact result */
1460#define FPE_FLTINV 7 /* floating point invalid operation */
1461#define FPE_FLTSUB 8 /* subscript out of range */
1462#define SEGV_MAPERR 1 /* address not mapped to object */
1463#define SEGV_ACCERR 2 /* invalid permissions for mapped object */
1464#define BUS_ADRALN 1 /* invalid address alignment */
1465#define BUS_ADRERR 2 /* non-existant physical address */
1466#define BUS_OBJERR 3 /* object specific hardware error */
1467#define TRAP_BRKPT 1 /* process breakpoint */
1468#define TRAP_TRACE 2 /* process trace trap */
1469#define CLD_EXITED 1 /* child has exited */
1470#define CLD_KILLED 2 /* child was killed */
1471#define CLD_DUMPED 3 /* child terminated abnormally */
1472#define CLD_TRAPPED 4 /* traced child has trapped */
1473#define CLD_STOPPED 5 /* child has stopped */
1474#define CLD_CONTINUED 6 /* stopped child has continued */
1475#define POLL_IN 1 /* data input available */
1476#define POLL_OUT 2 /* output buffers available */
1477#define POLL_MSG 3 /* input message available */
1478#define POLL_ERR 4 /* i/o error */
1479#define POLL_PRI 5 /* high priority input available */
1480#define POLL_HUP 6 /* device disconnected */
1481#define SI_USER 0 /* sent by kill, sigsend, raise */
1482#define SI_QUEUE -1 /* sent by sigqueue */
1483#define SI_TIMER -2 /* sent by timer expiration */
1484#define SI_MESGQ -3 /* sent by real time mesq state change */
1485#define SI_ASYNCIO -4 /* sent by AIO completion */
1486#else
1487#undef si_pid
1488#undef si_uid
1489#undef si_status
1490#undef si_utime
1491#undef si_stime
1492#undef si_value
1493#undef si_int
1494#undef si_ptr
1495#undef si_addr
1496#undef si_band
1497#undef si_fd
1498#endif
1499
1500static struct xlat sigill_flags[] = {
1501 {ILL_ILLOPC, "ILL_ILLOPC"},
1502 {ILL_ILLOPN, "ILL_ILLOPN"},
1503 {ILL_ILLADR, "ILL_ILLADR"},
1504 {ILL_ILLTRP, "ILL_ILLTRP"},
1505 {ILL_PRVOPC, "ILL_PRVOPC"},
1506 {ILL_PRVREG, "ILL_PRVREG"},
1507 {ILL_COPROC, "ILL_COPROC"},
1508 {ILL_BADSTK, "ILL_BADSTK"},
1509 {0, NULL}
1510};
1511
1512static struct xlat sigfpe_flags[] = {
1513 {FPE_INTDIV, "FPE_INTDIV"},
1514 {FPE_INTOVF, "FPE_INTOVF"},
1515 {FPE_FLTDIV, "FPE_FLTDIV"},
1516 {FPE_FLTOVF, "FPE_FLTOVF"},
1517 {FPE_FLTUND, "FPE_FLTUND"},
1518 {FPE_FLTRES, "FPE_FLTRES"},
1519 {FPE_FLTINV, "FPE_FLTINV"},
1520 {FPE_FLTSUB, "FPE_FLTSUB"},
1521 {0, NULL}
1522};
1523
1524static struct xlat sigsegv_flags[] = {
1525 {SEGV_MAPERR, "SEGV_MAPERR"},
1526 {SEGV_ACCERR, "SEGV_ACCERR"},
1527 {0, NULL}
1528};
1529
1530static struct xlat sigbus_flags[] = {
1531 {BUS_ADRALN, "BUS_ADRALN"},
1532 {BUS_ADRERR, "BUS_ADRERR"},
1533 {BUS_OBJERR, "BUS_OBJERR"},
1534 {0, NULL}
1535};
1536
1537static struct xlat sigtrap_flags[] = {
1538 {TRAP_BRKPT, "TRAP_BRKPT"},
1539 {TRAP_TRACE, "TRAP_TRACE"},
1540 {0, NULL}
1541};
1542
1543static struct xlat sigchld_flags[] = {
1544 {CLD_EXITED, "CLD_EXITED"},
1545 {CLD_KILLED, "CLD_KILLED"},
1546 {CLD_DUMPED, "CLD_DUMPED"},
1547 {CLD_TRAPPED, "CLD_TRAPPED"},
1548 {CLD_STOPPED, "CLD_STOPPED"},
1549 {CLD_CONTINUED, "CLD_CONTINUED"},
1550 {0, NULL}
1551};
1552
1553static struct xlat sigpoll_flags[] = {
1554 {POLL_IN, "POLL_IN"},
1555 {POLL_OUT, "POLL_OUT"},
1556 {POLL_MSG, "POLL_MSG"},
1557 {POLL_ERR, "POLL_ERR"},
1558 {POLL_PRI, "POLL_PRI"},
1559 {POLL_HUP, "POLL_HUP"},
1560 {0, NULL}
1561};
1562
1563static struct xlat siginfo_flags[] = {
1564 {SI_USER, "SI_USER"},
1565 {SI_QUEUE, "SI_QUEUE"},
1566 {SI_TIMER, "SI_TIMER"},
1567 {SI_MESGQ, "SI_MESGQ"},
1568 {SI_ASYNCIO, "SI_ASYNCIO"},
1569 {0, NULL}
1570};
1571
1572 static void
1573printsiginfo(tcp, si)
1574 struct tcb *tcp;
1575 siginfo_t *si;
1576{
1577 tprintf("{si_signo=");
1578 printsignal(si->si_signo);
1579 tprintf(", si_errno=%d, si_code=", si->si_errno);
1580 switch(si->si_signo)
1581 {
1582 case SIGILL:
1583 if (!printflags(sigill_flags, si->si_code))
1584 tprintf("%d /* ILL_??? */", si->si_code);
1585 tprintf(", si_addr=%lx",
1586 (unsigned long) si->_sifields._sigfault.si_addr);
1587 break;
1588 case SIGFPE:
1589 if (!printflags(sigfpe_flags, si->si_code))
1590 tprintf("%d /* FPE_??? */", si->si_code);
1591 tprintf(", si_addr=%lx",
1592 (unsigned long) si->_sifields._sigfault.si_addr);
1593 break;
1594 case SIGSEGV:
1595 if (!printflags(sigsegv_flags, si->si_code))
1596 tprintf("%d /* SEGV_??? */", si->si_code);
1597 tprintf(", si_addr=%lx",
1598 (unsigned long) si->_sifields._sigfault.si_addr);
1599 break;
1600 case SIGBUS:
1601 if (!printflags(sigbus_flags, si->si_code))
1602 tprintf("%d /* BUS_??? */", si->si_code);
1603 tprintf(", si_addr=%lx",
1604 (unsigned long) si->_sifields._sigfault.si_addr);
1605 break;
1606 case SIGTRAP:
1607 if (!printflags(sigtrap_flags, si->si_code))
1608 tprintf("%d /* TRAP_??? */", si->si_code);
1609 break;
1610 case SIGCHLD:
1611 if (!printflags(sigchld_flags, si->si_code))
1612 tprintf("%d /* CLD_??? */", si->si_code);
1613 if (!verbose(tcp))
1614 tprintf(", ...");
1615 else
1616 tprintf(", si_pid=%d, si_uid=%d, si_status=%d, si_utime=%lu, si_stime=%lu",
1617 si->_sifields._kill.si_pid,
1618 si->_sifields._kill.si_uid,
1619 si->_sifields._sigchld.si_status,
1620 si->_sifields._sigchld.si_utime,
1621 si->_sifields._sigchld.si_stime);
1622 break;
1623 case SIGPOLL:
1624 if (!printflags(sigpoll_flags, si->si_code))
1625 tprintf("%d /* POLL_??? */", si->si_code);
1626 if (si->si_code == POLL_IN
1627 || si->si_code == POLL_OUT
1628 || si->si_code == POLL_MSG)
1629 tprintf(", si_bind=%lu, si_fd=%d",
1630 (unsigned long) si->_sifields._sigpoll.si_band,
1631 si->_sifields._sigpoll.si_fd);
1632 break;
1633 default:
1634 if (!printflags(siginfo_flags, si->si_code))
1635 tprintf("%d /* SI_??? */", si->si_code);
1636 tprintf(", si_pid=%lu, si_uid=%lu, si_value={",
1637 (unsigned long) si->_sifields._rt.si_pid,
1638 (unsigned long) si->_sifields._rt.si_uid);
1639 if (!verbose(tcp))
1640 tprintf("...");
1641 else {
1642 tprintf("sival_int=%u, sival_ptr=%#lx",
1643 si->_sifields._rt.si_sigval.sival_int,
1644 (unsigned long) si->_sifields._rt.si_sigval.sival_ptr);
1645 }
1646 tprintf("}");
1647 break;
1648 }
1649 tprintf("}");
1650}
1651
1652 int
1653sys_rt_sigqueueinfo(tcp)
1654 struct tcb *tcp;
1655{
1656 if (entering(tcp)) {
1657 siginfo_t si;
1658 tprintf("%lu, ", tcp->u_arg[0]);
1659 printsignal(tcp->u_arg[1]);
1660 tprintf(", ");
1661 if (umove(tcp, tcp->u_arg[2], &si) < 0)
1662 tprintf("%#lx", tcp->u_arg[2]);
1663 else
1664 printsiginfo(&si);
1665 }
1666 return 0;
1667}
1668
1669int sys_rt_sigtimedwait(tcp)
1670 struct tcb *tcp;
1671{
1672 if (entering(tcp)) {
1673 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001674
Nate Sammons4a121431999-04-06 01:19:39 +00001675 if (copy_sigset_len(tcp, tcp->u_arg[0],
1676 &sigset, tcp->u_arg[3]) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001677 tprintf("[?]");
1678 else
Wichert Akkerman46956571999-11-26 10:12:59 +00001679 printsigmask(&sigset, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001680 tprintf(", ");
1681 }
1682 else {
1683 if (syserror(tcp))
1684 tprintf("%#lx", tcp->u_arg[0]);
1685 else {
1686 siginfo_t si;
1687 if (umove(tcp, tcp->u_arg[1], &si) < 0)
1688 tprintf("%#lx", tcp->u_arg[1]);
1689 else
1690 printsiginfo(&si);
1691 /* XXX For now */
1692 tprintf(", %#lx", tcp->u_arg[2]);
1693 tprintf(", %d", (int) tcp->u_arg[3]);
1694 }
1695 }
1696 return 0;
1697};
1698
1699#endif /* LINUX */
1700