17c478bd9Sstevel@tonic-gate /* 2*5d54f3d8Smuffin * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 3*5d54f3d8Smuffin * Use is subject to license terms. 47c478bd9Sstevel@tonic-gate */ 57c478bd9Sstevel@tonic-gate 67c478bd9Sstevel@tonic-gate /* 7*5d54f3d8Smuffin * Copyright (c) 1982 Regents of the University of California. 8*5d54f3d8Smuffin * All rights reserved. The Berkeley software License Agreement 9*5d54f3d8Smuffin * specifies the terms and conditions for redistribution. 107c478bd9Sstevel@tonic-gate */ 117c478bd9Sstevel@tonic-gate 127c478bd9Sstevel@tonic-gate #ifndef __sys_signal_h 137c478bd9Sstevel@tonic-gate #define __sys_signal_h 147c478bd9Sstevel@tonic-gate 157c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 167c478bd9Sstevel@tonic-gate 177c478bd9Sstevel@tonic-gate #include <vm/faultcode.h> 187c478bd9Sstevel@tonic-gate #define NSIG 32 197c478bd9Sstevel@tonic-gate 207c478bd9Sstevel@tonic-gate /* 217c478bd9Sstevel@tonic-gate * If any signal defines (SIG*) are added, deleted, or changed, the same 227c478bd9Sstevel@tonic-gate * changes must be made in /usr/include/signal.h as well. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate #define SIGHUP 1 /* hangup */ 257c478bd9Sstevel@tonic-gate #define SIGINT 2 /* interrupt */ 267c478bd9Sstevel@tonic-gate #define SIGQUIT 3 /* quit */ 277c478bd9Sstevel@tonic-gate #define SIGILL 4 /* illegal instruction (not reset when caught) */ 28*5d54f3d8Smuffin 297c478bd9Sstevel@tonic-gate #define ILL_STACK 0x00 /* bad stack */ 307c478bd9Sstevel@tonic-gate #define ILL_ILLINSTR_FAULT 0x02 /* illegal instruction fault */ 317c478bd9Sstevel@tonic-gate #define ILL_PRIVINSTR_FAULT 0x03 /* privileged instruction fault */ 327c478bd9Sstevel@tonic-gate /* codes from 0x80 to 0xff are software traps */ 337c478bd9Sstevel@tonic-gate #define ILL_TRAP_FAULT(n) ((n)+0x80) /* trap n fault */ 34*5d54f3d8Smuffin 357c478bd9Sstevel@tonic-gate #define SIGTRAP 5 /* trace trap (not reset when caught) */ 367c478bd9Sstevel@tonic-gate #define SIGIOT 6 /* IOT instruction */ 377c478bd9Sstevel@tonic-gate #define SIGABRT 6 /* used by abort, replace SIGIOT in the future */ 387c478bd9Sstevel@tonic-gate #define SIGEMT 7 /* EMT instruction */ 39*5d54f3d8Smuffin 407c478bd9Sstevel@tonic-gate #define EMT_TAG 0x0a /* tag overflow */ 41*5d54f3d8Smuffin 427c478bd9Sstevel@tonic-gate #define SIGFPE 8 /* floating point exception */ 43*5d54f3d8Smuffin 447c478bd9Sstevel@tonic-gate #define FPE_INTOVF_TRAP 0x1 /* integer overflow */ 457c478bd9Sstevel@tonic-gate #define FPE_STARTSIG_TRAP 0x2 /* process using fp */ 467c478bd9Sstevel@tonic-gate #define FPE_INTDIV_TRAP 0x14 /* integer divide by zero */ 477c478bd9Sstevel@tonic-gate #define FPE_FLTINEX_TRAP 0xc4 /* [floating inexact result] */ 487c478bd9Sstevel@tonic-gate #define FPE_FLTDIV_TRAP 0xc8 /* [floating divide by zero] */ 497c478bd9Sstevel@tonic-gate #define FPE_FLTUND_TRAP 0xcc /* [floating underflow] */ 507c478bd9Sstevel@tonic-gate #define FPE_FLTOPERR_TRAP 0xd0 /* [floating operand error] */ 517c478bd9Sstevel@tonic-gate #define FPE_FLTOVF_TRAP 0xd4 /* [floating overflow] */ 52*5d54f3d8Smuffin 537c478bd9Sstevel@tonic-gate #define SIGKILL 9 /* kill (cannot be caught or ignored) */ 547c478bd9Sstevel@tonic-gate /* 557c478bd9Sstevel@tonic-gate * The codes for SIGBUS and SIGSEGV are described in <vm/faultcode.h> 567c478bd9Sstevel@tonic-gate */ 577c478bd9Sstevel@tonic-gate #define SIGBUS 10 /* bus error */ 587c478bd9Sstevel@tonic-gate #define BUS_HWERR FC_HWERR /* misc hardware error (e.g. timeout) */ 597c478bd9Sstevel@tonic-gate #define BUS_ALIGN FC_ALIGN /* hardware alignment error */ 607c478bd9Sstevel@tonic-gate #define BUS_OBJERR FC_OBJERR /* object returned errno value */ 617c478bd9Sstevel@tonic-gate /* 627c478bd9Sstevel@tonic-gate * The BUS_CODE(code) will be one of the above. In the BUS_OBJERR case, 637c478bd9Sstevel@tonic-gate * doing a BUS_ERRNO(code) gives an errno value reported by the underlying 647c478bd9Sstevel@tonic-gate * file object mapped at the fault address. Note that this appears to be 657c478bd9Sstevel@tonic-gate * duplicated with the segmentation fault case below -- unfortunate, since 667c478bd9Sstevel@tonic-gate * the specification has always claimed that such errors produce SIGBUS. 677c478bd9Sstevel@tonic-gate * The segmentation cases are left defined as a transition aid. 687c478bd9Sstevel@tonic-gate */ 697c478bd9Sstevel@tonic-gate #define BUS_CODE(C) FC_CODE(C) 707c478bd9Sstevel@tonic-gate #define BUS_ERRNO(C) FC_ERRNO(C) 717c478bd9Sstevel@tonic-gate #define SIGSEGV 11 /* segmentation violation */ 727c478bd9Sstevel@tonic-gate #define SEGV_NOMAP FC_NOMAP /* no mapping at the fault address */ 737c478bd9Sstevel@tonic-gate #define SEGV_PROT FC_PROT /* access exceeded protections */ 747c478bd9Sstevel@tonic-gate #define SEGV_OBJERR FC_OBJERR /* object returned errno value */ 757c478bd9Sstevel@tonic-gate /* 767c478bd9Sstevel@tonic-gate * The SEGV_CODE(code) will be SEGV_NOMAP, SEGV_PROT, or SEGV_OBJERR. 777c478bd9Sstevel@tonic-gate * In the SEGV_OBJERR case, doing a SEGV_ERRNO(code) gives an errno value 787c478bd9Sstevel@tonic-gate * reported by the underlying file object mapped at the fault address. 797c478bd9Sstevel@tonic-gate */ 807c478bd9Sstevel@tonic-gate #define SEGV_CODE(C) FC_CODE(C) 817c478bd9Sstevel@tonic-gate #define SEGV_ERRNO(C) FC_ERRNO(C) 827c478bd9Sstevel@tonic-gate #define SIGSYS 12 /* bad argument to system call */ 837c478bd9Sstevel@tonic-gate #define SIGPIPE 13 /* write on a pipe with no one to read it */ 847c478bd9Sstevel@tonic-gate #define SIGALRM 14 /* alarm clock */ 857c478bd9Sstevel@tonic-gate #define SIGTERM 15 /* software termination signal from kill */ 867c478bd9Sstevel@tonic-gate #define SIGURG 16 /* urgent condition on IO channel */ 877c478bd9Sstevel@tonic-gate #define SIGSTOP 17 /* sendable stop signal not from tty */ 887c478bd9Sstevel@tonic-gate #define SIGTSTP 18 /* stop signal from tty */ 897c478bd9Sstevel@tonic-gate #define SIGCONT 19 /* continue a stopped process */ 907c478bd9Sstevel@tonic-gate #define SIGCHLD 20 /* to parent on child stop or exit */ 917c478bd9Sstevel@tonic-gate #define SIGCLD 20 /* System V name for SIGCHLD */ 927c478bd9Sstevel@tonic-gate #define SIGTTIN 21 /* to readers pgrp upon background tty read */ 937c478bd9Sstevel@tonic-gate #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ 947c478bd9Sstevel@tonic-gate #define SIGIO 23 /* input/output possible signal */ 957c478bd9Sstevel@tonic-gate #define SIGPOLL SIGIO /* System V name for SIGIO */ 967c478bd9Sstevel@tonic-gate #define SIGXCPU 24 /* exceeded CPU time limit */ 977c478bd9Sstevel@tonic-gate #define SIGXFSZ 25 /* exceeded file size limit */ 987c478bd9Sstevel@tonic-gate #define SIGVTALRM 26 /* virtual time alarm */ 997c478bd9Sstevel@tonic-gate #define SIGPROF 27 /* profiling time alarm */ 1007c478bd9Sstevel@tonic-gate #define SIGWINCH 28 /* window changed */ 1017c478bd9Sstevel@tonic-gate #define SIGLOST 29 /* resource lost (eg, record-lock lost) */ 1027c478bd9Sstevel@tonic-gate #define SIGUSR1 30 /* user defined signal 1 */ 1037c478bd9Sstevel@tonic-gate #define SIGUSR2 31 /* user defined signal 2 */ 1047c478bd9Sstevel@tonic-gate /* 1057c478bd9Sstevel@tonic-gate * If addr cannot be computed it is set to SIG_NOADDR. 1067c478bd9Sstevel@tonic-gate */ 1077c478bd9Sstevel@tonic-gate #define SIG_NOADDR ((char *)~0) 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate #if !defined(KERNEL) && !defined(LOCORE) 1107c478bd9Sstevel@tonic-gate void (*signal())(); 1117c478bd9Sstevel@tonic-gate /* 1127c478bd9Sstevel@tonic-gate * Define BSD 4.1 reliable signals for SVID compatibility. 1137c478bd9Sstevel@tonic-gate * These functions may go away in a future release. 1147c478bd9Sstevel@tonic-gate */ 1157c478bd9Sstevel@tonic-gate void (*sigset())(); 1167c478bd9Sstevel@tonic-gate int sighold(); 1177c478bd9Sstevel@tonic-gate int sigrelse(); 1187c478bd9Sstevel@tonic-gate int sigignore(); 119*5d54f3d8Smuffin #endif /* !KERNEL && !LOCORE */ 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate #ifndef LOCORE 1227c478bd9Sstevel@tonic-gate /* 1237c478bd9Sstevel@tonic-gate * Signal vector "template" used in sigvec call. 1247c478bd9Sstevel@tonic-gate */ 1257c478bd9Sstevel@tonic-gate struct sigvec { 1267c478bd9Sstevel@tonic-gate void (*sv_handler)(); /* signal handler */ 1277c478bd9Sstevel@tonic-gate int sv_mask; /* signal mask to apply */ 1287c478bd9Sstevel@tonic-gate int sv_flags; /* see signal options below */ 1297c478bd9Sstevel@tonic-gate }; 1307c478bd9Sstevel@tonic-gate #define SV_ONSTACK 0x0001 /* take signal on signal stack */ 1317c478bd9Sstevel@tonic-gate #define SV_INTERRUPT 0x0002 /* do not restart system on signal return */ 1327c478bd9Sstevel@tonic-gate #define SV_RESETHAND 0x0004 /* reset signal handler to SIG_DFL when signal taken */ 1337c478bd9Sstevel@tonic-gate /* 1347c478bd9Sstevel@tonic-gate * If any SA_NOCLDSTOP or SV_NOCLDSTOP is change, the same 1357c478bd9Sstevel@tonic-gate * changes must be made in /usr/include/signal.h as well. 1367c478bd9Sstevel@tonic-gate */ 1377c478bd9Sstevel@tonic-gate #define SV_NOCLDSTOP 0x0008 /* don't send a SIGCHLD on child stop */ 1387c478bd9Sstevel@tonic-gate #define SA_ONSTACK SV_ONSTACK 1397c478bd9Sstevel@tonic-gate #define SA_INTERRUPT SV_INTERRUPT 1407c478bd9Sstevel@tonic-gate #define SA_RESETHAND SV_RESETHAND 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate #define SA_NOCLDSTOP SV_NOCLDSTOP 1437c478bd9Sstevel@tonic-gate #define sv_onstack sv_flags /* isn't compatibility wonderful! */ 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate /* 1467c478bd9Sstevel@tonic-gate * Structure used in sigstack call. 1477c478bd9Sstevel@tonic-gate */ 1487c478bd9Sstevel@tonic-gate struct sigstack { 1497c478bd9Sstevel@tonic-gate char *ss_sp; /* signal stack pointer */ 1507c478bd9Sstevel@tonic-gate int ss_onstack; /* current status */ 1517c478bd9Sstevel@tonic-gate }; 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate /* 1547c478bd9Sstevel@tonic-gate * Information pushed on stack when a signal is delivered. 1557c478bd9Sstevel@tonic-gate * This is used by the kernel to restore state following 1567c478bd9Sstevel@tonic-gate * execution of the signal handler. It is also made available 1577c478bd9Sstevel@tonic-gate * to the handler to allow it to properly restore state if 1587c478bd9Sstevel@tonic-gate * a non-standard exit is performed. 1597c478bd9Sstevel@tonic-gate */ 1607c478bd9Sstevel@tonic-gate struct sigcontext { 1617c478bd9Sstevel@tonic-gate int sc_onstack; /* sigstack state to restore */ 1627c478bd9Sstevel@tonic-gate int sc_mask; /* signal mask to restore */ 1637c478bd9Sstevel@tonic-gate #define SPARC_MAXREGWINDOW 31 /* max usable windows in sparc */ 1647c478bd9Sstevel@tonic-gate int sc_sp; /* sp to restore */ 1657c478bd9Sstevel@tonic-gate int sc_pc; /* pc to retore */ 1667c478bd9Sstevel@tonic-gate int sc_npc; /* next pc to restore */ 1677c478bd9Sstevel@tonic-gate int sc_psr; /* psr to restore */ 1687c478bd9Sstevel@tonic-gate int sc_g1; /* register that must be restored */ 1697c478bd9Sstevel@tonic-gate int sc_o0; 1707c478bd9Sstevel@tonic-gate int sc_wbcnt; /* number of outstanding windows */ 1717c478bd9Sstevel@tonic-gate char *sc_spbuf[SPARC_MAXREGWINDOW]; /* sp's for each wbuf */ 1727c478bd9Sstevel@tonic-gate int sc_wbuf[SPARC_MAXREGWINDOW][16]; /* window save buf */ 1737c478bd9Sstevel@tonic-gate }; 174*5d54f3d8Smuffin #endif /* !LOCORE */ 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate #define BADSIG (void (*)())-1 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate /* 1797c478bd9Sstevel@tonic-gate * If SIG_ERR, SIG_DFL, SIG_IGN, or SIG_HOLD are changed, the same changes 1807c478bd9Sstevel@tonic-gate * must be made in /usr/include/signal.h as well. 1817c478bd9Sstevel@tonic-gate */ 1827c478bd9Sstevel@tonic-gate #define SIG_ERR (void (*)())-1 1837c478bd9Sstevel@tonic-gate #define SIG_DFL (void (*)())0 1847c478bd9Sstevel@tonic-gate #define SIG_IGN (void (*)())1 1857c478bd9Sstevel@tonic-gate 1867c478bd9Sstevel@tonic-gate #define SIG_HOLD (void (*)())3 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate /* 1897c478bd9Sstevel@tonic-gate * Macro for converting signal number to a mask suitable for sigblock(). 1907c478bd9Sstevel@tonic-gate */ 1917c478bd9Sstevel@tonic-gate #define sigmask(m) (1 << ((m)-1)) 1927c478bd9Sstevel@tonic-gate /* 1937c478bd9Sstevel@tonic-gate * signals that can't caught, blocked, or ignored 1947c478bd9Sstevel@tonic-gate */ 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate /* 1977c478bd9Sstevel@tonic-gate * If SIG_BLOCK, SIG_UNBLOCK, or SIG_SETMASK are changed, the same changes 1987c478bd9Sstevel@tonic-gate * must be made in /usr/include/signal.h as well. 1997c478bd9Sstevel@tonic-gate */ 2007c478bd9Sstevel@tonic-gate #define SIG_BLOCK 0x0001 2017c478bd9Sstevel@tonic-gate #define SIG_UNBLOCK 0x0002 2027c478bd9Sstevel@tonic-gate #define SIG_SETMASK 0x0004 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate #if !defined(LOCORE) && !defined(KERNEL) 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate /* 2077c478bd9Sstevel@tonic-gate * If changes are made to sigset_t or struct sigaction, the same changes 2087c478bd9Sstevel@tonic-gate * must be made in /usr/include/signal.h as well. 2097c478bd9Sstevel@tonic-gate */ 2107c478bd9Sstevel@tonic-gate #include <sys/stdtypes.h> 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate struct sigaction { 2137c478bd9Sstevel@tonic-gate void (*sa_handler)(); 2147c478bd9Sstevel@tonic-gate sigset_t sa_mask; 2157c478bd9Sstevel@tonic-gate int sa_flags; 2167c478bd9Sstevel@tonic-gate }; 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate /* 2197c478bd9Sstevel@tonic-gate * If changes are made to the function prototypes, the same changes 2207c478bd9Sstevel@tonic-gate * must be made in /usr/include/signal.h as well. 2217c478bd9Sstevel@tonic-gate */ 2227c478bd9Sstevel@tonic-gate void (*signal())(); 2237c478bd9Sstevel@tonic-gate int kill(/* pid_t p, int sig */); 2247c478bd9Sstevel@tonic-gate int sigaction(/* int signo, 2257c478bd9Sstevel@tonic-gate struct sigaction *act, struct sigaction *oldact */); 2267c478bd9Sstevel@tonic-gate int sigaddset(/* sigset_t *mask, int signo */); 2277c478bd9Sstevel@tonic-gate int sigdelset(/* sigset_t *mask, int signo */); 2287c478bd9Sstevel@tonic-gate int sigemptyset(/* sigset_t *mask */); 2297c478bd9Sstevel@tonic-gate int sigfillset(/* sigset_t *mask */); 2307c478bd9Sstevel@tonic-gate int sigismember(/* sigset_t *mask, int signo */); 2317c478bd9Sstevel@tonic-gate int sigpending(/* sigset_t *set */); 2327c478bd9Sstevel@tonic-gate int sigprocmask(/* int how, sigset_t *set, *oldset */); 2337c478bd9Sstevel@tonic-gate int sigsuspend(/* sigset_t *mask */); 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate #endif /* !LOCORE && !KERNEL */ 2367c478bd9Sstevel@tonic-gate #endif /* !__sys_signal_h */ 237