blob: 6051d8ff144ee738e505461ac6cf39d24f8d887e [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 Akkerman00a82ee2001-03-28 20:29:17 +000066#if HAVE_ASM_REG_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000067#ifdef SPARC
Wichert Akkerman00a82ee2001-03-28 20:29:17 +000068# define fpq kernel_fpq
69# define fq kernel_fq
70# define fpu kernel_fpu
71#endif
Wichert Akkerman9ce1a631999-08-29 23:15:07 +000072#include <asm/reg.h>
Wichert Akkerman00a82ee2001-03-28 20:29:17 +000073#ifdef SPARC
74# undef fpq
75# undef fq
76# undef fpu
77#endif
78
79#endif /* HAVE_ASM_REG_H */
80#ifdef HAVE_ASM_SIGCONTEXT_H
81#ifdef SPARC
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000082typedef struct {
Wichert Akkerman9ce1a631999-08-29 23:15:07 +000083 struct regs si_regs;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000084 int si_mask;
85} m_siginfo_t;
Wichert Akkerman00a82ee2001-03-28 20:29:17 +000086#else
87#include <asm/sigcontext.h>
88#endif /* SPARC */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000089#else /* !HAVE_ASM_SIGCONTEXT_H */
90#ifdef I386
91struct sigcontext_struct {
92 unsigned short gs, __gsh;
93 unsigned short fs, __fsh;
94 unsigned short es, __esh;
95 unsigned short ds, __dsh;
96 unsigned long edi;
97 unsigned long esi;
98 unsigned long ebp;
99 unsigned long esp;
100 unsigned long ebx;
101 unsigned long edx;
102 unsigned long ecx;
103 unsigned long eax;
104 unsigned long trapno;
105 unsigned long err;
106 unsigned long eip;
107 unsigned short cs, __csh;
108 unsigned long eflags;
109 unsigned long esp_at_signal;
110 unsigned short ss, __ssh;
111 unsigned long i387;
112 unsigned long oldmask;
113 unsigned long cr2;
114};
115#else /* !I386 */
116#ifdef M68K
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000117struct sigcontext
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000118{
119 unsigned long sc_mask;
120 unsigned long sc_usp;
121 unsigned long sc_d0;
122 unsigned long sc_d1;
123 unsigned long sc_a0;
124 unsigned long sc_a1;
125 unsigned short sc_sr;
126 unsigned long sc_pc;
127 unsigned short sc_formatvec;
128};
129#endif /* M68K */
130#endif /* !I386 */
131#endif /* !HAVE_ASM_SIGCONTEXT_H */
132#ifndef NSIG
133#define NSIG 32
134#endif
135#ifdef ARM
136#undef NSIG
137#define NSIG 32
138#endif
139#endif /* LINUX */
140
141char *signalent0[] = {
142#include "signalent.h"
143};
144int nsignals0 = sizeof signalent0 / sizeof signalent0[0];
145
146#if SUPPORTED_PERSONALITIES >= 2
147char *signalent1[] = {
148#include "signalent1.h"
149};
150int nsignals1 = sizeof signalent1 / sizeof signalent1[0];
151#endif /* SUPPORTED_PERSONALITIES >= 2 */
152
153#if SUPPORTED_PERSONALITIES >= 3
154char *signalent2[] = {
155#include "signalent2.h"
156};
157int nsignals2 = sizeof signalent2 / sizeof signalent2[0];
158#endif /* SUPPORTED_PERSONALITIES >= 3 */
159
160char **signalent;
161int nsignals;
162
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000163#if defined(SUNOS4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000164
165static struct xlat sigvec_flags[] = {
166 { SV_ONSTACK, "SV_ONSTACK" },
167 { SV_INTERRUPT, "SV_INTERRUPT" },
168 { SV_RESETHAND, "SV_RESETHAND" },
169 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
170 { 0, NULL },
171};
172
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000173#endif /* SUNOS4 || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000174
175#ifdef HAVE_SIGACTION
176
177static struct xlat sigact_flags[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000178#ifdef SA_RESTORER
179 { SA_RESTORER, "SA_RESTORER" },
180#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000181#ifdef SA_STACK
182 { SA_STACK, "SA_STACK" },
183#endif
184#ifdef SA_RESTART
185 { SA_RESTART, "SA_RESTART" },
186#endif
187#ifdef SA_INTERRUPT
188 { SA_INTERRUPT, "SA_INTERRUPT" },
189#endif
190#ifdef SA_NOMASK
191 { SA_NOMASK, "SA_NOMASK" },
192#endif
193#ifdef SA_ONESHOT
194 { SA_ONESHOT, "SA_ONESHOT" },
195#endif
196#ifdef SA_SIGINFO
197 { SA_SIGINFO, "SA_SIGINFO" },
198#endif
199#ifdef SA_RESETHAND
200 { SA_RESETHAND, "SA_RESETHAND" },
201#endif
202#ifdef SA_ONSTACK
203 { SA_ONSTACK, "SA_ONSTACK" },
204#endif
205#ifdef SA_NODEFER
206 { SA_NODEFER, "SA_NODEFER" },
207#endif
208#ifdef SA_NOCLDSTOP
209 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
210#endif
211#ifdef SA_NOCLDWAIT
212 { SA_NOCLDWAIT, "SA_NOCLDWAIT" },
213#endif
214#ifdef _SA_BSDCALL
215 { _SA_BSDCALL, "_SA_BSDCALL" },
216#endif
217 { 0, NULL },
218};
219
220static struct xlat sigprocmaskcmds[] = {
221 { SIG_BLOCK, "SIG_BLOCK" },
222 { SIG_UNBLOCK, "SIG_UNBLOCK" },
223 { SIG_SETMASK, "SIG_SETMASK" },
224#ifdef SIG_SETMASK32
225 { SIG_SETMASK32,"SIG_SETMASK32" },
226#endif
227 { 0, NULL },
228};
229
230#endif /* HAVE_SIGACTION */
231
Nate Sammonsce780fc1999-03-29 23:23:13 +0000232/* Anonymous realtime signals. */
233/* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a
234 constant. This is what we want. Otherwise, just use SIGRTMIN. */
235#ifdef SIGRTMIN
236#ifndef __SIGRTMIN
237#define __SIGRTMIN SIGRTMIN
238#define __SIGRTMAX SIGRTMAX /* likewise */
239#endif
240#endif
241
242char *
243signame(sig)
244int sig;
245{
246 static char buf[30];
247 if (sig < nsignals) {
248 return signalent[sig];
249#ifdef SIGRTMIN
Nate Sammons3080aa41999-03-30 00:16:41 +0000250 } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000251 sprintf(buf, "SIGRT_%ld", (long)(sig - __SIGRTMIN));
Nate Sammonsce780fc1999-03-29 23:23:13 +0000252 return buf;
253#endif /* SIGRTMIN */
254 } else {
255 sprintf(buf, "%d", sig);
256 return buf;
257 }
258}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000259
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000260#ifndef UNIXWARE
Nate Sammons4a121431999-04-06 01:19:39 +0000261static void
262long_to_sigset(l, s)
263long l;
264sigset_t *s;
265{
266 sigemptyset(s);
267 *(long *)s = l;
268}
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000269#endif
Nate Sammons4a121431999-04-06 01:19:39 +0000270
271static int
272copy_sigset_len(tcp, addr, s, len)
273struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000274long addr;
Nate Sammons4a121431999-04-06 01:19:39 +0000275sigset_t *s;
276int len;
277{
278 if (len > sizeof(*s))
279 len = sizeof(*s);
280 sigemptyset(s);
281 if (umoven(tcp, addr, len, (char *)s) < 0)
282 return -1;
283 return 0;
284}
285
286#ifdef LINUX
287/* Original sigset is unsigned long */
288#define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(long))
289#else
290#define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(sigset_t))
291#endif
292
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000293static char *
Nate Sammons4a121431999-04-06 01:19:39 +0000294sprintsigmask(s, mask, rt)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000295char *s;
296sigset_t *mask;
Nate Sammons4a121431999-04-06 01:19:39 +0000297int rt; /* set might include realtime sigs */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000298{
299 int i, nsigs;
Nate Sammons4a121431999-04-06 01:19:39 +0000300 int maxsigs;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000301 char *format;
302 static char outstr[256];
303
304 strcpy(outstr, s);
305 s = outstr + strlen(outstr);
306 nsigs = 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000307 maxsigs = nsignals;
308#ifdef __SIGRTMAX
309 if (rt)
310 maxsigs = __SIGRTMAX; /* instead */
311#endif
312 for (i = 1; i < maxsigs; i++) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000313 if (sigismember(mask, i) == 1)
314 nsigs++;
315 }
316 if (nsigs >= nsignals * 2 / 3) {
317 *s++ = '~';
Nate Sammons4a121431999-04-06 01:19:39 +0000318 for (i = 1; i < maxsigs; i++) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000319 switch (sigismember(mask, i)) {
320 case 1:
321 sigdelset(mask, i);
322 break;
323 case 0:
324 sigaddset(mask, i);
325 break;
326 }
327 }
328 }
329 format = "%s";
330 *s++ = '[';
Nate Sammons4a121431999-04-06 01:19:39 +0000331 for (i = 1; i < maxsigs; i++) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000332 if (sigismember(mask, i) == 1) {
John Hughesbdf48f52001-03-06 15:08:09 +0000333 /* real-time signals on solaris don't have
334 * signalent entries
335 */
336 if (i < nsignals) {
337 sprintf(s, format, signalent[i] + 3);
338 }
339 else {
340 char tsig[32];
341 sprintf(tsig, "%u", i);
342 sprintf(s, format, tsig);
343 }
344 s += strlen(s);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000345 format = " %s";
346 }
347 }
348 *s++ = ']';
349 *s = '\0';
350 return outstr;
351}
352
353static void
Nate Sammons4a121431999-04-06 01:19:39 +0000354printsigmask(mask, rt)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000355sigset_t *mask;
Nate Sammons4a121431999-04-06 01:19:39 +0000356int rt;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000357{
Nate Sammons4a121431999-04-06 01:19:39 +0000358 tprintf("%s", sprintsigmask("", mask, rt));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000359}
360
361void
362printsignal(nr)
363int nr;
364{
Nate Sammonsce780fc1999-03-29 23:23:13 +0000365 tprintf(signame(nr));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000366}
367
368/*
369 * Check process TCP for the disposition of signal SIG.
370 * Return 1 if the process would somehow manage to survive signal SIG,
371 * else return 0. This routine will never be called with SIGKILL.
372 */
373int
374sigishandled(tcp, sig)
375struct tcb *tcp;
376int sig;
377{
378#ifdef LINUX
379 int sfd;
380 char sname[32];
381 char buf[1024];
382 char *s;
383 int i;
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000384 unsigned int signalled, blocked, ignored, caught;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000385
386 /* This is incredibly costly but it's worth it. */
387 sprintf(sname, "/proc/%d/stat", tcp->pid);
388 if ((sfd = open(sname, O_RDONLY)) == -1) {
389 perror(sname);
390 return 1;
391 }
392 i = read(sfd, buf, 1024);
393 buf[i] = '\0';
394 close(sfd);
395 /*
396 * Skip the extraneous fields. This loses if the
397 * command name has any spaces in it. So be it.
398 */
399 for (i = 0, s = buf; i < 30; i++) {
400 while (*++s != ' ') {
401 if (!*s)
402 break;
403 }
404 }
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000405 if (sscanf(s, "%u%u%u%u",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000406 &signalled, &blocked, &ignored, &caught) != 4) {
407 fprintf(stderr, "/proc/pid/stat format error\n");
408 return 1;
409 }
410#ifdef DEBUG
411 fprintf(stderr, "sigs: %08x %08x %08x %08x\n",
412 signalled, blocked, ignored, caught);
413#endif
414 if ((ignored & sigmask(sig)) || (caught & sigmask(sig)))
415 return 1;
416#endif /* LINUX */
417
418#ifdef SUNOS4
419 void (*u_signal)();
420
421 if (upeek(tcp->pid, uoff(u_signal[0]) + sig*sizeof(u_signal),
422 (long *) &u_signal) < 0) {
423 return 0;
424 }
425 if (u_signal != SIG_DFL)
426 return 1;
427#endif /* SUNOS4 */
428
429#ifdef SVR4
430 /*
431 * Since procfs doesn't interfere with wait I think it is safe
432 * to punt on this question. If not, the information is there.
433 */
434 return 1;
435#else /* !SVR4 */
436 switch (sig) {
437 case SIGCONT:
438 case SIGSTOP:
439 case SIGTSTP:
440 case SIGTTIN:
441 case SIGTTOU:
442 case SIGCHLD:
443 case SIGIO:
444#if defined(SIGURG) && SIGURG != SIGIO
445 case SIGURG:
446#endif
447 case SIGWINCH:
448 /* Gloria Gaynor says ... */
449 return 1;
450 default:
451 break;
452 }
453 return 0;
454#endif /* !SVR4 */
455}
456
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000457#if defined(SUNOS4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000458
459int
460sys_sigvec(tcp)
461struct tcb *tcp;
462{
463 struct sigvec sv;
464 long addr;
465
466 if (entering(tcp)) {
467 printsignal(tcp->u_arg[0]);
468 tprintf(", ");
469 addr = tcp->u_arg[1];
470 } else {
471 addr = tcp->u_arg[2];
472 }
473 if (addr == 0)
474 tprintf("NULL");
475 else if (!verbose(tcp))
476 tprintf("%#lx", addr);
477 else if (umove(tcp, addr, &sv) < 0)
478 tprintf("{...}");
479 else {
480 switch ((int) sv.sv_handler) {
481 case (int) SIG_ERR:
482 tprintf("{SIG_ERR}");
483 break;
484 case (int) SIG_DFL:
485 tprintf("{SIG_DFL}");
486 break;
487 case (int) SIG_IGN:
488 if (tcp->u_arg[0] == SIGTRAP) {
489 tcp->flags |= TCB_SIGTRAPPED;
490 kill(tcp->pid, SIGSTOP);
491 }
492 tprintf("{SIG_IGN}");
493 break;
494 case (int) SIG_HOLD:
495 if (tcp->u_arg[0] == SIGTRAP) {
496 tcp->flags |= TCB_SIGTRAPPED;
497 kill(tcp->pid, SIGSTOP);
498 }
499 tprintf("SIG_HOLD");
500 break;
501 default:
502 if (tcp->u_arg[0] == SIGTRAP) {
503 tcp->flags |= TCB_SIGTRAPPED;
504 kill(tcp->pid, SIGSTOP);
505 }
506 tprintf("{%#lx, ", (unsigned long) sv.sv_handler);
Nate Sammons4a121431999-04-06 01:19:39 +0000507 printsigmask(&sv.sv_mask, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000508 tprintf(", ");
509 if (!printflags(sigvec_flags, sv.sv_flags))
510 tprintf("0");
511 tprintf("}");
512 }
513 }
514 if (entering(tcp))
515 tprintf(", ");
516 return 0;
517}
518
519int
520sys_sigpause(tcp)
521struct tcb *tcp;
522{
523 if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */
Nate Sammons4a121431999-04-06 01:19:39 +0000524 sigset_t sigm;
525 long_to_sigset(tcp->u_arg[0], &sigm);
526 printsigmask(&sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000527 }
528 return 0;
529}
530
531int
532sys_sigstack(tcp)
533struct tcb *tcp;
534{
535 struct sigstack ss;
536 long addr;
537
538 if (entering(tcp))
539 addr = tcp->u_arg[0];
540 else
541 addr = tcp->u_arg[1];
542 if (addr == 0)
543 tprintf("NULL");
544 else if (umove(tcp, addr, &ss) < 0)
545 tprintf("%#lx", addr);
546 else {
547 tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp);
548 tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO");
549 }
550 if (entering(tcp))
551 tprintf(", ");
552 return 0;
553}
554
555int
556sys_sigcleanup(tcp)
557struct tcb *tcp;
558{
559 return 0;
560}
561
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000562#endif /* SUNOS4 || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000563
564#ifndef SVR4
565
566int
567sys_sigsetmask(tcp)
568struct tcb *tcp;
569{
570 if (entering(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000571 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000572 long_to_sigset(tcp->u_arg[0], &sigm);
573 printsigmask(&sigm, 0);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000574#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000575 if ((tcp->u_arg[0] & sigmask(SIGTRAP))) {
576 /* Mark attempt to block SIGTRAP */
577 tcp->flags |= TCB_SIGTRAPPED;
578 /* Send unblockable signal */
579 kill(tcp->pid, SIGSTOP);
580 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000581#endif /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000582 }
583 else if (!syserror(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000584 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000585 long_to_sigset(tcp->u_rval, &sigm);
586 tcp->auxstr = sprintsigmask("old mask ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000587
588 return RVAL_HEX | RVAL_STR;
589 }
590 return 0;
591}
592
593int
594sys_sigblock(tcp)
595struct tcb *tcp;
596{
597 return sys_sigsetmask(tcp);
598}
599
600#endif /* !SVR4 */
601
602#ifdef HAVE_SIGACTION
603
604#ifdef LINUX
605struct old_sigaction {
606 __sighandler_t __sa_handler;
607 unsigned long sa_mask;
608 unsigned long sa_flags;
609 void (*sa_restorer)(void);
610};
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000611#define SA_HANDLER __sa_handler
612#endif /* LINUX */
613
614#ifndef SA_HANDLER
615#define SA_HANDLER sa_handler
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000616#endif
617
618int
619sys_sigaction(tcp)
620struct tcb *tcp;
621{
622 long addr;
Nate Sammons4a121431999-04-06 01:19:39 +0000623#ifdef LINUX
John Hughes1e4cb342001-03-06 09:25:46 +0000624 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000625 struct old_sigaction sa;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000626#else
627 struct sigaction sa;
628#endif
629
630
631 if (entering(tcp)) {
632 printsignal(tcp->u_arg[0]);
633 tprintf(", ");
634 addr = tcp->u_arg[1];
635 } else
636 addr = tcp->u_arg[2];
637 if (addr == 0)
638 tprintf("NULL");
639 else if (!verbose(tcp))
640 tprintf("%#lx", addr);
641 else if (umove(tcp, addr, &sa) < 0)
642 tprintf("{...}");
643 else {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000644 switch ((long) sa.SA_HANDLER) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000645 case (long) SIG_ERR:
646 tprintf("{SIG_ERR}");
647 break;
648 case (long) SIG_DFL:
649 tprintf("{SIG_DFL}");
650 break;
651 case (long) SIG_IGN:
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000652#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000653 if (tcp->u_arg[0] == SIGTRAP) {
654 tcp->flags |= TCB_SIGTRAPPED;
655 kill(tcp->pid, SIGSTOP);
656 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000657#endif /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000658 tprintf("{SIG_IGN}");
659 break;
660 default:
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000661#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000662 if (tcp->u_arg[0] == SIGTRAP) {
663 tcp->flags |= TCB_SIGTRAPPED;
664 kill(tcp->pid, SIGSTOP);
665 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000666#endif /* !USE_PROCFS */
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000667 tprintf("{%#lx, ", (long) sa.SA_HANDLER);
Wichert Akkerman48214be1999-11-26 09:55:42 +0000668#ifndef LINUX
669 printsigmask (&sa.sa_mask, 0);
670#else
Nate Sammons4a121431999-04-06 01:19:39 +0000671 long_to_sigset(sa.sa_mask, &sigset);
672 printsigmask(&sigset, 0);
Wichert Akkerman48214be1999-11-26 09:55:42 +0000673#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000674 tprintf(", ");
675 if (!printflags(sigact_flags, sa.sa_flags))
676 tprintf("0");
677 tprintf("}");
678 }
679 }
680 if (entering(tcp))
681 tprintf(", ");
682#ifdef LINUX
683 else
684 tprintf(", %#lx", (unsigned long) sa.sa_restorer);
685#endif
686 return 0;
687}
688
689int
690sys_signal(tcp)
691struct tcb *tcp;
692{
693 if (entering(tcp)) {
694 printsignal(tcp->u_arg[0]);
Wichert Akkerman16a03d22000-08-10 02:14:04 +0000695 tprintf(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000696 switch (tcp->u_arg[1]) {
697 case (int) SIG_ERR:
698 tprintf("SIG_ERR");
699 break;
700 case (int) SIG_DFL:
701 tprintf("SIG_DFL");
702 break;
703 case (int) SIG_IGN:
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000704#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000705 if (tcp->u_arg[0] == SIGTRAP) {
706 tcp->flags |= TCB_SIGTRAPPED;
707 kill(tcp->pid, SIGSTOP);
708 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000709#endif /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000710 tprintf("SIG_IGN");
711 break;
712 default:
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000713#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000714 if (tcp->u_arg[0] == SIGTRAP) {
715 tcp->flags |= TCB_SIGTRAPPED;
716 kill(tcp->pid, SIGSTOP);
717 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000718#endif /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000719 tprintf("%#lx", tcp->u_arg[1]);
720 }
Wichert Akkerman16a03d22000-08-10 02:14:04 +0000721 return 0;
722 }
723 else {
724 switch (tcp->u_rval) {
725 case (int) SIG_ERR:
726 tcp->auxstr = "SIG_ERR"; break;
727 case (int) SIG_DFL:
728 tcp->auxstr = "SIG_DFL"; break;
729 case (int) SIG_IGN:
730 tcp->auxstr = "SIG_IGN"; break;
731 default:
732 tcp->auxstr = NULL;
733 }
734 return RVAL_HEX | RVAL_STR;
735 }
736}
737
738int
739sys_sighold(tcp)
740struct tcb *tcp;
741{
742 if (entering(tcp)) {
743 printsignal(tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000744 }
745 return 0;
746}
747
748#endif /* HAVE_SIGACTION */
749
750#ifdef LINUX
751
752int
753sys_sigreturn(tcp)
754struct tcb *tcp;
755{
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000756#ifdef S390
757 long usp;
758 struct sigcontext_struct sc;
759
760 if (entering(tcp)) {
761 tcp->u_arg[0] = 0;
762 if (upeek(tcp->pid,PT_GPR15,&usp)<0)
763 return 0;
764 if (umove(tcp, usp+__SIGNAL_FRAMESIZE, &sc) < 0)
765 return 0;
766 tcp->u_arg[0] = 1;
767 memcpy(&tcp->u_arg[1],&sc.oldmask[0],sizeof(sigset_t));
768 } else {
769 tcp->u_rval = tcp->u_error = 0;
770 if (tcp->u_arg[0] == 0)
771 return 0;
772 tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1]);
773 return RVAL_NONE | RVAL_STR;
774 }
775 return 0;
776#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000777#ifdef I386
778 long esp;
779 struct sigcontext_struct sc;
780
781 if (entering(tcp)) {
782 tcp->u_arg[0] = 0;
783 if (upeek(tcp->pid, 4*UESP, &esp) < 0)
784 return 0;
785 if (umove(tcp, esp, &sc) < 0)
786 return 0;
787 tcp->u_arg[0] = 1;
788 tcp->u_arg[1] = sc.oldmask;
789 }
790 else {
791 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000792 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000793 tcp->u_rval = tcp->u_error = 0;
794 if (tcp->u_arg[0] == 0)
795 return 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000796 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000797 return RVAL_NONE | RVAL_STR;
798 }
799 return 0;
800#else /* !I386 */
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000801#ifdef IA64
802 struct sigcontext sc;
803 long sp;
804
805 if (entering(tcp)) {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000806 /* offset of sigcontext in the kernel's sigframe structure: */
807# define SIGFRAME_SC_OFFSET 0x90
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000808 tcp->u_arg[0] = 0;
809 if (upeek(tcp->pid, PT_R12, &sp) < 0)
810 return 0;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000811 if (umove(tcp, sp + 16 + SIGFRAME_SC_OFFSET, &sc) < 0)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000812 return 0;
813 tcp->u_arg[0] = 1;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000814 memcpy(tcp->u_arg + 1, &sc.sc_mask, sizeof(sc.sc_mask));
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000815 }
816 else {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000817 sigset_t sigm;
818
819 memcpy(&sigm, tcp->u_arg + 1, sizeof (sigm));
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000820 tcp->u_rval = tcp->u_error = 0;
821 if (tcp->u_arg[0] == 0)
822 return 0;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000823 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000824 return RVAL_NONE | RVAL_STR;
825 }
826 return 0;
827#else /* !IA64 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000828#ifdef POWERPC
829 long esp;
830 struct sigcontext_struct sc;
831
832 if (entering(tcp)) {
833 tcp->u_arg[0] = 0;
834 if (upeek(tcp->pid, 4*PT_R1, &esp) < 0)
835 return 0;
836 if (umove(tcp, esp, &sc) < 0)
837 return 0;
838 tcp->u_arg[0] = 1;
839 tcp->u_arg[1] = sc.oldmask;
840 }
841 else {
842 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000843 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000844 tcp->u_rval = tcp->u_error = 0;
845 if (tcp->u_arg[0] == 0)
846 return 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000847 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000848 return RVAL_NONE | RVAL_STR;
849 }
850 return 0;
851#else /* !POWERPC */
852#ifdef M68K
853 long usp;
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000854 struct sigcontext sc;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000855
856 if (entering(tcp)) {
857 tcp->u_arg[0] = 0;
858 if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
859 return 0;
860 if (umove(tcp, usp, &sc) < 0)
861 return 0;
862 tcp->u_arg[0] = 1;
863 tcp->u_arg[1] = sc.sc_mask;
864 }
865 else {
866 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000867 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000868 tcp->u_rval = tcp->u_error = 0;
869 if (tcp->u_arg[0] == 0)
870 return 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000871 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000872 return RVAL_NONE | RVAL_STR;
873 }
874 return 0;
875#else /* !M68K */
876#ifdef ALPHA
877 long fp;
878 struct sigcontext_struct sc;
879
880 if (entering(tcp)) {
881 tcp->u_arg[0] = 0;
882 if (upeek(tcp->pid, REG_FP, &fp) < 0)
883 return 0;
884 if (umove(tcp, fp, &sc) < 0)
885 return 0;
886 tcp->u_arg[0] = 1;
887 tcp->u_arg[1] = sc.sc_mask;
888 }
889 else {
890 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000891 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000892 tcp->u_rval = tcp->u_error = 0;
893 if (tcp->u_arg[0] == 0)
894 return 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000895 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000896 return RVAL_NONE | RVAL_STR;
897 }
898 return 0;
899#else
900#ifdef SPARC
901 long i1;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000902 struct regs regs;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000903 m_siginfo_t si;
904
905 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)&regs, 0) < 0) {
906 perror("sigreturn: PTRACE_GETREGS ");
907 return 0;
908 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000909 if(entering(tcp)) {
910 tcp->u_arg[0] = 0;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000911 i1 = regs.r_o1;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000912 if(umove(tcp, i1, &si) < 0) {
913 perror("sigreturn: umove ");
914 return 0;
915 }
916 tcp->u_arg[0] = 1;
917 tcp->u_arg[1] = si.si_mask;
918 } else {
919 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000920 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000921 tcp->u_rval = tcp->u_error = 0;
922 if(tcp->u_arg[0] == 0)
923 return 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000924 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000925 return RVAL_NONE | RVAL_STR;
926 }
927 return 0;
Wichert Akkermanf90da011999-10-31 21:15:38 +0000928#else
929#ifdef MIPS
930 long sp;
931 struct sigcontext sc;
932
933 if(entering(tcp)) {
934 tcp->u_arg[0] = 0;
935 if (upeek(tcp->pid, REG_SP, &sp) < 0)
936 return 0;
937 if (umove(tcp, sp, &sc) < 0)
938 return 0;
939 tcp->u_arg[0] = 1;
940 tcp->u_arg[1] = sc.sc_sigset;
941 } else {
942 tcp->u_rval = tcp->u_error = 0;
943 if(tcp->u_arg[0] == 0)
944 return 0;
945 tcp->auxstr = sprintsigmask("mask now ", tcp->u_arg[1]);
946 return RVAL_NONE | RVAL_STR;
947 }
948 return 0;
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000949#else
950#ifdef HPPA
951#warning NO sys_sigreturn DECODE FOR HPPA
952 return 0;
953#endif /* HPPA */
Wichert Akkermanf90da011999-10-31 21:15:38 +0000954#endif /* MIPS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000955#endif /* SPARC */
956#endif /* ALPHA */
957#endif /* !M68K */
958#endif /* !POWERPC */
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000959#endif /* !IA64 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000960#endif /* !I386 */
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000961#endif /* S390 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000962}
963
964int
965sys_siggetmask(tcp)
966struct tcb *tcp;
967{
968 if (exiting(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000969 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000970 long_to_sigset(tcp->u_rval, &sigm);
971 tcp->auxstr = sprintsigmask("mask ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000972 }
973 return RVAL_HEX | RVAL_STR;
974}
975
976int
977sys_sigsuspend(tcp)
978struct tcb *tcp;
979{
980 if (entering(tcp)) {
981 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000982 long_to_sigset(tcp->u_arg[2], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000983#if 0
984 /* first two are not really arguments, but print them anyway */
985 /* nevermind, they are an anachronism now, too bad... */
986 tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
987#endif
Nate Sammons4a121431999-04-06 01:19:39 +0000988 printsigmask(&sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000989 }
990 return 0;
991}
992
993#endif /* LINUX */
994
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000995#if defined(SVR4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000996
997int
998sys_sigsuspend(tcp)
999struct tcb *tcp;
1000{
1001 sigset_t sigset;
1002
1003 if (entering(tcp)) {
1004 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
1005 tprintf("[?]");
1006 else
Wichert Akkerman46956571999-11-26 10:12:59 +00001007 printsigmask(&sigset, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001008 }
1009 return 0;
1010}
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001011#ifndef FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001012static struct xlat ucontext_flags[] = {
1013 { UC_SIGMASK, "UC_SIGMASK" },
1014 { UC_STACK, "UC_STACK" },
1015 { UC_CPU, "UC_CPU" },
1016#ifdef UC_FPU
1017 { UC_FPU, "UC_FPU" },
1018#endif
1019#ifdef UC_INTR
1020 { UC_INTR, "UC_INTR" },
1021#endif
1022 { 0, NULL },
1023};
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001024#endif /* !FREEBSD */
1025#endif /* SVR4 || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001026
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001027#if defined SVR4 || defined LINUX || defined FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001028#if defined LINUX && !defined SS_ONSTACK
1029#define SS_ONSTACK 1
1030#define SS_DISABLE 2
1031#if __GLIBC_MINOR__ == 0
1032typedef struct
1033{
1034 __ptr_t ss_sp;
1035 int ss_flags;
1036 size_t ss_size;
1037} stack_t;
1038#endif
1039#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001040#ifdef FREEBSD
1041#define stack_t struct sigaltstack
1042#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001043
1044static struct xlat sigaltstack_flags[] = {
1045 { SS_ONSTACK, "SS_ONSTACK" },
1046 { SS_DISABLE, "SS_DISABLE" },
1047 { 0, NULL },
1048};
1049#endif
1050
1051#ifdef SVR4
1052static void
1053printcontext(tcp, ucp)
1054struct tcb *tcp;
1055ucontext_t *ucp;
1056{
1057 tprintf("{");
1058 if (!abbrev(tcp)) {
1059 tprintf("uc_flags=");
1060 if (!printflags(ucontext_flags, ucp->uc_flags))
1061 tprintf("0");
1062 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
1063 }
1064 tprintf("uc_sigmask=");
Nate Sammons4a121431999-04-06 01:19:39 +00001065 printsigmask(ucp->uc_sigmask, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001066 if (!abbrev(tcp)) {
1067 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
1068 (unsigned long) ucp->uc_stack.ss_sp,
1069 ucp->uc_stack.ss_size);
1070 if (!printflags(sigaltstack_flags, ucp->uc_stack.ss_flags))
1071 tprintf("0");
1072 tprintf("}");
1073 }
1074 tprintf(", ...}");
1075}
1076
1077int
1078sys_getcontext(tcp)
1079struct tcb *tcp;
1080{
1081 ucontext_t uc;
1082
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001083 if (exiting(tcp)) {
1084 if (tcp->u_error)
1085 tprintf("%#lx", tcp->u_arg[0]);
1086 else if (!tcp->u_arg[0])
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001087 tprintf("NULL");
1088 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1089 tprintf("{...}");
1090 else
1091 printcontext(tcp, &uc);
1092 }
1093 return 0;
1094}
1095
1096int
1097sys_setcontext(tcp)
1098struct tcb *tcp;
1099{
1100 ucontext_t uc;
1101
1102 if (entering(tcp)) {
1103 if (!tcp->u_arg[0])
1104 tprintf("NULL");
1105 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1106 tprintf("{...}");
1107 else
1108 printcontext(tcp, &uc);
1109 }
1110 else {
1111 tcp->u_rval = tcp->u_error = 0;
1112 if (tcp->u_arg[0] == 0)
1113 return 0;
1114 return RVAL_NONE;
1115 }
1116 return 0;
1117}
1118
1119#endif /* SVR4 */
1120
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001121#if defined(LINUX) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001122
1123static int
1124print_stack_t(tcp, addr)
1125struct tcb *tcp;
1126unsigned long addr;
1127{
1128 stack_t ss;
1129 if (umove(tcp, addr, &ss) < 0)
1130 return -1;
1131 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
1132 if (!printflags(sigaltstack_flags, ss.ss_flags))
1133 tprintf("0");
1134 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
1135 return 0;
1136}
1137
1138int
1139sys_sigaltstack(tcp)
1140 struct tcb *tcp;
1141{
1142 if (entering(tcp)) {
1143 if (tcp->u_arg[0] == 0)
1144 tprintf("NULL");
1145 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
1146 return -1;
1147 }
1148 else {
1149 tprintf(", ");
1150 if (tcp->u_arg[1] == 0)
1151 tprintf("NULL");
1152 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
1153 return -1;
1154 }
1155 return 0;
1156}
1157#endif
1158
1159#ifdef HAVE_SIGACTION
1160
1161int
1162sys_sigprocmask(tcp)
1163struct tcb *tcp;
1164{
1165#ifdef ALPHA
1166 if (entering(tcp)) {
1167 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1168 tprintf(", ");
Nate Sammons4a121431999-04-06 01:19:39 +00001169 printsigmask(tcp->u_arg[1], 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001170 }
1171 else if (!syserror(tcp)) {
Nate Sammons4a121431999-04-06 01:19:39 +00001172 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001173 return RVAL_HEX | RVAL_STR;
1174 }
1175#else /* !ALPHA */
1176 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001177
1178 if (entering(tcp)) {
1179#ifdef SVR4
1180 if (tcp->u_arg[0] == 0)
1181 tprintf("0");
1182 else
1183#endif /* SVR4 */
1184 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1185 tprintf(", ");
1186 if (!tcp->u_arg[1])
1187 tprintf("NULL, ");
Nate Sammons4a121431999-04-06 01:19:39 +00001188 else if (copy_sigset(tcp, tcp->u_arg[1], &sigset) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001189 tprintf("%#lx, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001190 else {
Nate Sammons4a121431999-04-06 01:19:39 +00001191 printsigmask(&sigset, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001192 tprintf(", ");
1193 }
1194 }
1195 else {
1196 if (!tcp->u_arg[2])
1197 tprintf("NULL");
1198 else if (syserror(tcp))
1199 tprintf("%#lx", tcp->u_arg[2]);
Nate Sammons4a121431999-04-06 01:19:39 +00001200 else if (copy_sigset(tcp, tcp->u_arg[2], &sigset) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001201 tprintf("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001202 else
Nate Sammons4a121431999-04-06 01:19:39 +00001203 printsigmask(&sigset, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001204 }
1205#endif /* !ALPHA */
1206 return 0;
1207}
1208
1209#endif /* HAVE_SIGACTION */
1210
1211int
1212sys_kill(tcp)
1213struct tcb *tcp;
1214{
1215 if (entering(tcp)) {
Nate Sammonsce780fc1999-03-29 23:23:13 +00001216 tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001217 }
1218 return 0;
1219}
1220
1221int
1222sys_killpg(tcp)
1223struct tcb *tcp;
1224{
1225 return sys_kill(tcp);
1226}
1227
1228int
1229sys_sigpending(tcp)
1230struct tcb *tcp;
1231{
1232 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001233
1234 if (exiting(tcp)) {
1235 if (syserror(tcp))
1236 tprintf("%#lx", tcp->u_arg[0]);
Nate Sammons4a121431999-04-06 01:19:39 +00001237 else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001238 tprintf("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001239 else
Wichert Akkerman46956571999-11-26 10:12:59 +00001240 printsigmask(&sigset, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001241 }
1242 return 0;
1243}
1244
1245#ifdef LINUX
1246
1247 int
1248sys_rt_sigprocmask(tcp)
1249 struct tcb *tcp;
1250{
1251 sigset_t sigset;
1252
Nate Sammons4a121431999-04-06 01:19:39 +00001253 /* Note: arg[3] is the length of the sigset. */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001254 if (entering(tcp)) {
1255 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1256 tprintf(", ");
1257 if (!tcp->u_arg[1])
1258 tprintf("NULL, ");
Nate Sammons4a121431999-04-06 01:19:39 +00001259 else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001260 tprintf("%#lx, ", tcp->u_arg[1]);
1261 else {
Nate Sammons4a121431999-04-06 01:19:39 +00001262 printsigmask(&sigset, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001263 tprintf(", ");
1264 }
1265 }
1266 else {
1267 if (!tcp->u_arg[2])
1268
1269 tprintf("NULL");
1270 else if (syserror(tcp))
1271 tprintf("%#lx", tcp->u_arg[2]);
Nate Sammons4a121431999-04-06 01:19:39 +00001272 else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001273 tprintf("[?]");
1274 else
Nate Sammons4a121431999-04-06 01:19:39 +00001275 printsigmask(&sigset, 1);
Nate Sammonsdab325a1999-03-29 23:33:35 +00001276 tprintf(", %lu", tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001277 }
1278 return 0;
1279}
1280
1281#if __GLIBC_MINOR__ < 1
1282/* Type for data associated with a signal. */
1283typedef union sigval
1284{
1285 int sival_int;
1286 void *sival_ptr;
1287} sigval_t;
1288
1289# define __SI_MAX_SIZE 128
1290# define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
1291
1292typedef struct siginfo
1293{
1294 int si_signo; /* Signal number. */
1295 int si_errno; /* If non-zero, an errno value associated with
1296 this signal, as defined in <errno.h>. */
1297 int si_code; /* Signal code. */
1298
1299 union
1300 {
1301 int _pad[__SI_PAD_SIZE];
1302
1303 /* kill(). */
1304 struct
1305 {
1306 __pid_t si_pid; /* Sending process ID. */
1307 __uid_t si_uid; /* Real user ID of sending process. */
1308 } _kill;
1309
1310 /* POSIX.1b timers. */
1311 struct
1312 {
1313 unsigned int _timer1;
1314 unsigned int _timer2;
1315 } _timer;
1316
1317 /* POSIX.1b signals. */
1318 struct
1319 {
1320 __pid_t si_pid; /* Sending process ID. */
1321 __uid_t si_uid; /* Real user ID of sending process. */
1322 sigval_t si_sigval; /* Signal value. */
1323 } _rt;
1324
1325 /* SIGCHLD. */
1326 struct
1327 {
1328 __pid_t si_pid; /* Which child. */
1329 int si_status; /* Exit value or signal. */
1330 __clock_t si_utime;
1331 __clock_t si_stime;
1332 } _sigchld;
1333
1334 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
1335 struct
1336 {
1337 void *si_addr; /* Faulting insn/memory ref. */
1338 } _sigfault;
1339
1340 /* SIGPOLL. */
1341 struct
1342 {
1343 int si_band; /* Band event for SIGPOLL. */
1344 int si_fd;
1345 } _sigpoll;
1346 } _sifields;
1347} siginfo_t;
1348#endif
1349
1350/* Structure describing the action to be taken when a signal arrives. */
1351struct new_sigaction
1352{
1353 union
1354 {
1355 __sighandler_t __sa_handler;
1356 void (*__sa_sigaction) (int, siginfo_t *, void *);
1357 }
1358 __sigaction_handler;
1359 unsigned long sa_flags;
1360 void (*sa_restorer) (void);
1361 unsigned long int sa_mask[2];
1362};
1363
1364
1365 int
1366sys_rt_sigaction(tcp)
1367 struct tcb *tcp;
1368{
1369 struct new_sigaction sa;
1370 sigset_t sigset;
1371 long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001372
1373 if (entering(tcp)) {
1374 printsignal(tcp->u_arg[0]);
1375 tprintf(", ");
1376 addr = tcp->u_arg[1];
1377 } else
1378 addr = tcp->u_arg[2];
1379 if (addr == 0)
1380 tprintf("NULL");
1381 else if (!verbose(tcp))
1382 tprintf("%#lx", addr);
1383 else if (umove(tcp, addr, &sa) < 0)
1384 tprintf("{...}");
1385 else {
1386 switch ((long) sa.__sigaction_handler.__sa_handler) {
1387 case (long) SIG_ERR:
1388 tprintf("{SIG_ERR}");
1389 break;
1390 case (long) SIG_DFL:
1391 tprintf("{SIG_DFL}");
1392 break;
1393 case (long) SIG_IGN:
1394 tprintf("{SIG_IGN}");
1395 break;
1396 default:
1397 tprintf("{%#lx, ",
1398 (long) sa.__sigaction_handler.__sa_handler);
Nate Sammons4a121431999-04-06 01:19:39 +00001399 sigemptyset(&sigset);
Wichert Akkermandacfb6e1999-06-03 14:21:07 +00001400#ifdef LINUXSPARC
1401 if (tcp->u_arg[4] <= sizeof(sigset))
1402 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
1403#else
Nate Sammons4a121431999-04-06 01:19:39 +00001404 if (tcp->u_arg[3] <= sizeof(sigset))
1405 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
Wichert Akkermandacfb6e1999-06-03 14:21:07 +00001406#endif
Nate Sammons4a121431999-04-06 01:19:39 +00001407 else
1408 memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
1409 printsigmask(&sigset, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001410 tprintf(", ");
1411 if (!printflags(sigact_flags, sa.sa_flags))
1412 tprintf("0");
1413 tprintf("}");
1414 }
1415 }
1416 if (entering(tcp))
1417 tprintf(", ");
1418 else
Wichert Akkermandacfb6e1999-06-03 14:21:07 +00001419#ifdef LINUXSPARC
1420 tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
1421#elif defined(ALPHA)
1422 tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
1423#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001424 tprintf(", %lu", addr = tcp->u_arg[3]);
Wichert Akkermandacfb6e1999-06-03 14:21:07 +00001425#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001426 return 0;
1427}
1428
1429 int
1430sys_rt_sigpending(tcp)
1431 struct tcb *tcp;
1432{
1433 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001434
1435 if (exiting(tcp)) {
1436 if (syserror(tcp))
1437 tprintf("%#lx", tcp->u_arg[0]);
Nate Sammons4a121431999-04-06 01:19:39 +00001438 else if (copy_sigset_len(tcp, tcp->u_arg[0],
1439 &sigset, tcp->u_arg[1]) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001440 tprintf("[?]");
1441 else
Wichert Akkerman46956571999-11-26 10:12:59 +00001442 printsigmask(&sigset, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001443 }
1444 return 0;
1445}
1446 int
1447sys_rt_sigsuspend(tcp)
1448 struct tcb *tcp;
1449{
1450 if (entering(tcp)) {
1451 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +00001452 if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0)
1453 tprintf("[?]");
1454 else
1455 printsigmask(&sigm, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001456 }
1457 return 0;
1458}
1459#ifndef ILL_ILLOPC
1460#define ILL_ILLOPC 1 /* illegal opcode */
1461#define ILL_ILLOPN 2 /* illegal operand */
1462#define ILL_ILLADR 3 /* illegal addressing mode */
1463#define ILL_ILLTRP 4 /* illegal trap */
1464#define ILL_PRVOPC 5 /* privileged opcode */
1465#define ILL_PRVREG 6 /* privileged register */
1466#define ILL_COPROC 7 /* coprocessor error */
1467#define ILL_BADSTK 8 /* internal stack error */
1468#define FPE_INTDIV 1 /* integer divide by zero */
1469#define FPE_INTOVF 2 /* integer overflow */
1470#define FPE_FLTDIV 3 /* floating point divide by zero */
1471#define FPE_FLTOVF 4 /* floating point overflow */
1472#define FPE_FLTUND 5 /* floating point underflow */
1473#define FPE_FLTRES 6 /* floating point inexact result */
1474#define FPE_FLTINV 7 /* floating point invalid operation */
1475#define FPE_FLTSUB 8 /* subscript out of range */
1476#define SEGV_MAPERR 1 /* address not mapped to object */
1477#define SEGV_ACCERR 2 /* invalid permissions for mapped object */
1478#define BUS_ADRALN 1 /* invalid address alignment */
1479#define BUS_ADRERR 2 /* non-existant physical address */
1480#define BUS_OBJERR 3 /* object specific hardware error */
1481#define TRAP_BRKPT 1 /* process breakpoint */
1482#define TRAP_TRACE 2 /* process trace trap */
1483#define CLD_EXITED 1 /* child has exited */
1484#define CLD_KILLED 2 /* child was killed */
1485#define CLD_DUMPED 3 /* child terminated abnormally */
1486#define CLD_TRAPPED 4 /* traced child has trapped */
1487#define CLD_STOPPED 5 /* child has stopped */
1488#define CLD_CONTINUED 6 /* stopped child has continued */
1489#define POLL_IN 1 /* data input available */
1490#define POLL_OUT 2 /* output buffers available */
1491#define POLL_MSG 3 /* input message available */
1492#define POLL_ERR 4 /* i/o error */
1493#define POLL_PRI 5 /* high priority input available */
1494#define POLL_HUP 6 /* device disconnected */
1495#define SI_USER 0 /* sent by kill, sigsend, raise */
1496#define SI_QUEUE -1 /* sent by sigqueue */
1497#define SI_TIMER -2 /* sent by timer expiration */
1498#define SI_MESGQ -3 /* sent by real time mesq state change */
1499#define SI_ASYNCIO -4 /* sent by AIO completion */
1500#else
1501#undef si_pid
1502#undef si_uid
1503#undef si_status
1504#undef si_utime
1505#undef si_stime
1506#undef si_value
1507#undef si_int
1508#undef si_ptr
1509#undef si_addr
1510#undef si_band
1511#undef si_fd
1512#endif
1513
1514static struct xlat sigill_flags[] = {
1515 {ILL_ILLOPC, "ILL_ILLOPC"},
1516 {ILL_ILLOPN, "ILL_ILLOPN"},
1517 {ILL_ILLADR, "ILL_ILLADR"},
1518 {ILL_ILLTRP, "ILL_ILLTRP"},
1519 {ILL_PRVOPC, "ILL_PRVOPC"},
1520 {ILL_PRVREG, "ILL_PRVREG"},
1521 {ILL_COPROC, "ILL_COPROC"},
1522 {ILL_BADSTK, "ILL_BADSTK"},
1523 {0, NULL}
1524};
1525
1526static struct xlat sigfpe_flags[] = {
1527 {FPE_INTDIV, "FPE_INTDIV"},
1528 {FPE_INTOVF, "FPE_INTOVF"},
1529 {FPE_FLTDIV, "FPE_FLTDIV"},
1530 {FPE_FLTOVF, "FPE_FLTOVF"},
1531 {FPE_FLTUND, "FPE_FLTUND"},
1532 {FPE_FLTRES, "FPE_FLTRES"},
1533 {FPE_FLTINV, "FPE_FLTINV"},
1534 {FPE_FLTSUB, "FPE_FLTSUB"},
1535 {0, NULL}
1536};
1537
1538static struct xlat sigsegv_flags[] = {
1539 {SEGV_MAPERR, "SEGV_MAPERR"},
1540 {SEGV_ACCERR, "SEGV_ACCERR"},
1541 {0, NULL}
1542};
1543
1544static struct xlat sigbus_flags[] = {
1545 {BUS_ADRALN, "BUS_ADRALN"},
1546 {BUS_ADRERR, "BUS_ADRERR"},
1547 {BUS_OBJERR, "BUS_OBJERR"},
1548 {0, NULL}
1549};
1550
1551static struct xlat sigtrap_flags[] = {
1552 {TRAP_BRKPT, "TRAP_BRKPT"},
1553 {TRAP_TRACE, "TRAP_TRACE"},
1554 {0, NULL}
1555};
1556
1557static struct xlat sigchld_flags[] = {
1558 {CLD_EXITED, "CLD_EXITED"},
1559 {CLD_KILLED, "CLD_KILLED"},
1560 {CLD_DUMPED, "CLD_DUMPED"},
1561 {CLD_TRAPPED, "CLD_TRAPPED"},
1562 {CLD_STOPPED, "CLD_STOPPED"},
1563 {CLD_CONTINUED, "CLD_CONTINUED"},
1564 {0, NULL}
1565};
1566
1567static struct xlat sigpoll_flags[] = {
1568 {POLL_IN, "POLL_IN"},
1569 {POLL_OUT, "POLL_OUT"},
1570 {POLL_MSG, "POLL_MSG"},
1571 {POLL_ERR, "POLL_ERR"},
1572 {POLL_PRI, "POLL_PRI"},
1573 {POLL_HUP, "POLL_HUP"},
1574 {0, NULL}
1575};
1576
1577static struct xlat siginfo_flags[] = {
1578 {SI_USER, "SI_USER"},
1579 {SI_QUEUE, "SI_QUEUE"},
1580 {SI_TIMER, "SI_TIMER"},
1581 {SI_MESGQ, "SI_MESGQ"},
1582 {SI_ASYNCIO, "SI_ASYNCIO"},
1583 {0, NULL}
1584};
1585
1586 static void
1587printsiginfo(tcp, si)
1588 struct tcb *tcp;
1589 siginfo_t *si;
1590{
1591 tprintf("{si_signo=");
1592 printsignal(si->si_signo);
1593 tprintf(", si_errno=%d, si_code=", si->si_errno);
1594 switch(si->si_signo)
1595 {
1596 case SIGILL:
1597 if (!printflags(sigill_flags, si->si_code))
1598 tprintf("%d /* ILL_??? */", si->si_code);
1599 tprintf(", si_addr=%lx",
1600 (unsigned long) si->_sifields._sigfault.si_addr);
1601 break;
1602 case SIGFPE:
1603 if (!printflags(sigfpe_flags, si->si_code))
1604 tprintf("%d /* FPE_??? */", si->si_code);
1605 tprintf(", si_addr=%lx",
1606 (unsigned long) si->_sifields._sigfault.si_addr);
1607 break;
1608 case SIGSEGV:
1609 if (!printflags(sigsegv_flags, si->si_code))
1610 tprintf("%d /* SEGV_??? */", si->si_code);
1611 tprintf(", si_addr=%lx",
1612 (unsigned long) si->_sifields._sigfault.si_addr);
1613 break;
1614 case SIGBUS:
1615 if (!printflags(sigbus_flags, si->si_code))
1616 tprintf("%d /* BUS_??? */", si->si_code);
1617 tprintf(", si_addr=%lx",
1618 (unsigned long) si->_sifields._sigfault.si_addr);
1619 break;
1620 case SIGTRAP:
1621 if (!printflags(sigtrap_flags, si->si_code))
1622 tprintf("%d /* TRAP_??? */", si->si_code);
1623 break;
1624 case SIGCHLD:
1625 if (!printflags(sigchld_flags, si->si_code))
1626 tprintf("%d /* CLD_??? */", si->si_code);
1627 if (!verbose(tcp))
1628 tprintf(", ...");
1629 else
1630 tprintf(", si_pid=%d, si_uid=%d, si_status=%d, si_utime=%lu, si_stime=%lu",
1631 si->_sifields._kill.si_pid,
1632 si->_sifields._kill.si_uid,
1633 si->_sifields._sigchld.si_status,
1634 si->_sifields._sigchld.si_utime,
1635 si->_sifields._sigchld.si_stime);
1636 break;
1637 case SIGPOLL:
1638 if (!printflags(sigpoll_flags, si->si_code))
1639 tprintf("%d /* POLL_??? */", si->si_code);
1640 if (si->si_code == POLL_IN
1641 || si->si_code == POLL_OUT
1642 || si->si_code == POLL_MSG)
1643 tprintf(", si_bind=%lu, si_fd=%d",
1644 (unsigned long) si->_sifields._sigpoll.si_band,
1645 si->_sifields._sigpoll.si_fd);
1646 break;
1647 default:
1648 if (!printflags(siginfo_flags, si->si_code))
1649 tprintf("%d /* SI_??? */", si->si_code);
1650 tprintf(", si_pid=%lu, si_uid=%lu, si_value={",
1651 (unsigned long) si->_sifields._rt.si_pid,
1652 (unsigned long) si->_sifields._rt.si_uid);
1653 if (!verbose(tcp))
1654 tprintf("...");
1655 else {
1656 tprintf("sival_int=%u, sival_ptr=%#lx",
1657 si->_sifields._rt.si_sigval.sival_int,
1658 (unsigned long) si->_sifields._rt.si_sigval.sival_ptr);
1659 }
1660 tprintf("}");
1661 break;
1662 }
1663 tprintf("}");
1664}
1665
1666 int
1667sys_rt_sigqueueinfo(tcp)
1668 struct tcb *tcp;
1669{
1670 if (entering(tcp)) {
1671 siginfo_t si;
1672 tprintf("%lu, ", tcp->u_arg[0]);
1673 printsignal(tcp->u_arg[1]);
1674 tprintf(", ");
1675 if (umove(tcp, tcp->u_arg[2], &si) < 0)
1676 tprintf("%#lx", tcp->u_arg[2]);
1677 else
1678 printsiginfo(&si);
1679 }
1680 return 0;
1681}
1682
1683int sys_rt_sigtimedwait(tcp)
1684 struct tcb *tcp;
1685{
1686 if (entering(tcp)) {
1687 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001688
Nate Sammons4a121431999-04-06 01:19:39 +00001689 if (copy_sigset_len(tcp, tcp->u_arg[0],
1690 &sigset, tcp->u_arg[3]) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001691 tprintf("[?]");
1692 else
Wichert Akkerman46956571999-11-26 10:12:59 +00001693 printsigmask(&sigset, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001694 tprintf(", ");
1695 }
1696 else {
1697 if (syserror(tcp))
1698 tprintf("%#lx", tcp->u_arg[0]);
1699 else {
1700 siginfo_t si;
1701 if (umove(tcp, tcp->u_arg[1], &si) < 0)
1702 tprintf("%#lx", tcp->u_arg[1]);
1703 else
1704 printsiginfo(&si);
1705 /* XXX For now */
1706 tprintf(", %#lx", tcp->u_arg[2]);
1707 tprintf(", %d", (int) tcp->u_arg[3]);
1708 }
1709 }
1710 return 0;
1711};
1712
1713#endif /* LINUX */
1714