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