1 /* sys/signal.h */ 2 3 #ifndef _SYS_SIGNAL_H 4 #define _SYS_SIGNAL_H 5 6 #ifdef __cplusplus 7 extern "C" { 8 #endif 9 10 #include "_ansi.h" 11 #include <sys/features.h> 12 13 /* #ifndef __STRICT_ANSI__*/ 14 15 #if defined(_POSIX_THREADS) 16 #include <sys/types.h> /* for pthread data types */ 17 #endif 18 19 typedef unsigned long sigset_t; 20 21 #if defined(__rtems__) 22 23 #if defined(_POSIX_REALTIME_SIGNALS) 24 25 /* sigev_notify values 26 NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD. */ 27 28 #define SIGEV_NONE 1 /* No asynchronous notification shall be delivered */ 29 /* when the event of interest occurs. */ 30 #define SIGEV_SIGNAL 2 /* A queued signal, with an application defined */ 31 /* value, shall be delivered when the event of */ 32 /* interest occurs. */ 33 #define SIGEV_THREAD 3 /* A notification function shall be called to */ 34 /* perform notification. */ 35 36 /* Signal Generation and Delivery, P1003.1b-1993, p. 63 37 NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and 38 sigev_notify_attributes to the sigevent structure. */ 39 40 union sigval { 41 int sival_int; /* Integer signal value */ 42 void *sival_ptr; /* Pointer signal value */ 43 }; 44 45 struct sigevent { 46 int sigev_notify; /* Notification type */ 47 int sigev_signo; /* Signal number */ 48 union sigval sigev_value; /* Signal value */ 49 50 #if defined(_POSIX_THREADS) 51 void (*sigev_notify_function)( union sigval ); 52 /* Notification function */ 53 pthread_attr_t *sigev_notify_attributes; /* Notification Attributes */ 54 #endif 55 }; 56 57 /* Signal Actions, P1003.1b-1993, p. 64 */ 58 /* si_code values, p. 66 */ 59 60 #define SI_USER 1 /* Sent by a user. kill(), abort(), etc */ 61 #define SI_QUEUE 2 /* Sent by sigqueue() */ 62 #define SI_TIMER 3 /* Sent by expiration of a timer_settime() timer */ 63 #define SI_ASYNCIO 4 /* Indicates completion of asycnhronous IO */ 64 #define SI_MESGQ 5 /* Indicates arrival of a message at an empty queue */ 65 66 typedef struct { 67 int si_signo; /* Signal number */ 68 int si_code; /* Cause of the signal */ 69 union sigval si_value; /* Signal value */ 70 } siginfo_t; 71 #endif 72 73 /* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */ 74 75 #define SA_NOCLDSTOP 1 /* Do not generate SIGCHLD when children stop */ 76 #define SA_SIGINFO 2 /* Invoke the signal catching function with */ 77 /* three arguments instead of one. */ 78 79 /* struct sigaction notes from POSIX: 80 * 81 * (1) Routines stored in sa_handler should take a single int as 82 * there argument although the POSIX standard does not require this. 83 * (2) The fields sa_handler and sa_sigaction may overlap, and a conforming 84 * application should not use both simultaneously. 85 */ 86 87 struct sigaction { 88 int sa_flags; /* Special flags to affect behavior of signal */ 89 sigset_t sa_mask; /* Additional set of signals to be blocked */ 90 /* during execution of signal-catching */ 91 /* function. */ 92 union { 93 void (*_handler)(); /* SIG_DFL, SIG_IGN, or pointer to a function */ 94 #if defined(_POSIX_REALTIME_SIGNALS) 95 void (*_sigaction)( int, siginfo_t *, void * ); 96 #endif 97 } _signal_handlers; 98 }; 99 100 #define sa_handler _signal_handlers._handler 101 #if defined(_POSIX_REALTIME_SIGNALS) 102 #define sa_sigaction _signal_handlers._sigaction 103 #endif 104 105 #else 106 107 struct sigaction 108 { 109 void (*sa_handler)(int); 110 sigset_t sa_mask; 111 int sa_flags; 112 }; 113 114 #define SA_NOCLDSTOP 1 /* only value supported now for sa_flags */ 115 116 #ifdef __CYGWIN__ 117 # define SA_RESTART 0x10000000 /* Restart syscall on signal return. */ 118 # define SA_NODEFER 0x40000000 /* Don't automatically block the signal when 119 its handler is being executed. */ 120 # define SA_RESETHAND 0x80000000 /* Reset to SIG_DFL on entry to handler. */ 121 #endif 122 123 #endif /* defined(__rtems__) */ 124 125 #define SIG_SETMASK 0 /* set mask with sigprocmask() */ 126 #define SIG_BLOCK 1 /* set of signals to block */ 127 #define SIG_UNBLOCK 2 /* set of signals to, well, unblock */ 128 129 /* These depend upon the type of sigset_t, which right now 130 is always a long.. They're in the POSIX namespace, but 131 are not ANSI. */ 132 #define sigaddset(what,sig) (*(what) |= (1<<(sig))) 133 #define sigemptyset(what) (*(what) = 0) 134 135 int _EXFUN(sigprocmask, (int how, const sigset_t *set, sigset_t *oset)); 136 137 #if defined(_POSIX_THREADS) 138 int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset)); 139 #endif 140 141 /* protos for functions found in winsup sources for CYGWIN */ 142 #if defined(__CYGWIN__) || defined(__rtems__) 143 #undef sigaddset 144 #undef sigemptyset 145 /* The first argument to kill should be pid_t. Right now 146 <sys/types.h> always defines pid_t to be int. If that ever 147 changes, then we will need to do something else, perhaps along the 148 lines of <machine/types.h>. */ 149 int _EXFUN(kill, (int, int)); 150 int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *)); 151 int _EXFUN(sigaddset, (sigset_t *, const int)); 152 int _EXFUN(sigdelset, (sigset_t *, const int)); 153 int _EXFUN(sigismember, (const sigset_t *, int)); 154 int _EXFUN(sigfillset, (sigset_t *)); 155 int _EXFUN(sigemptyset, (sigset_t *)); 156 int _EXFUN(sigpending, (sigset_t *)); 157 int _EXFUN(sigsuspend, (const sigset_t *)); 158 int _EXFUN(sigpause, (int)); 159 160 #if defined(_POSIX_THREADS) 161 int _EXFUN(pthread_kill, (pthread_t thread, int sig)); 162 #endif 163 164 #if defined(_POSIX_REALTIME_SIGNALS) 165 166 /* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 167 NOTE: P1003.1c/D10, p. 39 adds sigwait(). */ 168 169 int _EXFUN(sigwaitinfo, (const sigset_t *set, siginfo_t *info)); 170 int _EXFUN(sigtimedwait, 171 (const sigset_t *set, siginfo_t *info, const struct timespec *timeout) 172 ); 173 int _EXFUN(sigwait, (const sigset_t *set, int *sig)); 174 175 /* 3.3.9 Queue a Signal to a Process, P1003.1b-1993, p. 78 */ 176 int _EXFUN(sigqueue, (pid_t pid, int signo, const union sigval value)); 177 178 #endif /* defined(_POSIX_REALTIME_SIGNALS) */ 179 180 #endif /* defined(__CYGWIN32__) || defined(__rtems__) */ 181 182 /* #endif __STRICT_ANSI__ */ 183 184 #if defined(___AM29K__) 185 /* These all need to be defined for ANSI C, but I don't think they are 186 meaningful. */ 187 #define SIGABRT 1 188 #define SIGFPE 1 189 #define SIGILL 1 190 #define SIGINT 1 191 #define SIGSEGV 1 192 #define SIGTERM 1 193 /* These need to be defined for POSIX, and some others do too. */ 194 #define SIGHUP 1 195 #define SIGQUIT 1 196 #define NSIG 2 197 #elif defined(__GO32__) 198 #define SIGINT 1 199 #define SIGKILL 2 200 #define SIGPIPE 3 201 #define SIGFPE 4 202 #define SIGHUP 5 203 #define SIGTERM 6 204 #define SIGSEGV 7 205 #define SIGTSTP 8 206 #define SIGQUIT 9 207 #define SIGTRAP 10 208 #define SIGILL 11 209 #define SIGEMT 12 210 #define SIGALRM 13 211 #define SIGBUS 14 212 #define SIGLOST 15 213 #define SIGSTOP 16 214 #define SIGABRT 17 215 #define SIGUSR1 18 216 #define SIGUSR2 19 217 #define NSIG 20 218 #elif defined(__CYGWIN__) /* BSD signals semantics */ 219 #define SIGHUP 1 /* hangup */ 220 #define SIGINT 2 /* interrupt */ 221 #define SIGQUIT 3 /* quit */ 222 #define SIGILL 4 /* illegal instruction (not reset when caught) */ 223 #define SIGTRAP 5 /* trace trap (not reset when caught) */ 224 #define SIGABRT 6 /* used by abort */ 225 #define SIGEMT 7 /* EMT instruction */ 226 #define SIGFPE 8 /* floating point exception */ 227 #define SIGKILL 9 /* kill (cannot be caught or ignored) */ 228 #define SIGBUS 10 /* bus error */ 229 #define SIGSEGV 11 /* segmentation violation */ 230 #define SIGSYS 12 /* bad argument to system call */ 231 #define SIGPIPE 13 /* write on a pipe with no one to read it */ 232 #define SIGALRM 14 /* alarm clock */ 233 #define SIGTERM 15 /* software termination signal from kill */ 234 #define SIGURG 16 /* urgent condition on IO channel */ 235 #define SIGSTOP 17 /* sendable stop signal not from tty */ 236 #define SIGTSTP 18 /* stop signal from tty */ 237 #define SIGCONT 19 /* continue a stopped process */ 238 #define SIGCHLD 20 /* to parent on child stop or exit */ 239 #define SIGCLD 20 /* System V name for SIGCHLD */ 240 #define SIGTTIN 21 /* to readers pgrp upon background tty read */ 241 #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ 242 #define SIGIO 23 /* input/output possible signal */ 243 #define SIGPOLL SIGIO /* System V name for SIGIO */ 244 #define SIGXCPU 24 /* exceeded CPU time limit */ 245 #define SIGXFSZ 25 /* exceeded file size limit */ 246 #define SIGVTALRM 26 /* virtual time alarm */ 247 #define SIGPROF 27 /* profiling time alarm */ 248 #define SIGWINCH 28 /* window changed */ 249 #define SIGLOST 29 /* resource lost (eg, record-lock lost) */ 250 #define SIGUSR1 30 /* user defined signal 1 */ 251 #define SIGUSR2 31 /* user defined signal 2 */ 252 #define NSIG 32 /* signal 0 implied */ 253 #else 254 #define SIGHUP 1 /* hangup */ 255 #define SIGINT 2 /* interrupt */ 256 #define SIGQUIT 3 /* quit */ 257 #define SIGILL 4 /* illegal instruction (not reset when caught) */ 258 #define SIGTRAP 5 /* trace trap (not reset when caught) */ 259 #define SIGIOT 6 /* IOT instruction */ 260 #define SIGABRT 6 /* used by abort, replace SIGIOT in the future */ 261 #define SIGEMT 7 /* EMT instruction */ 262 #define SIGFPE 8 /* floating point exception */ 263 #define SIGKILL 9 /* kill (cannot be caught or ignored) */ 264 #define SIGBUS 10 /* bus error */ 265 #define SIGSEGV 11 /* segmentation violation */ 266 #define SIGSYS 12 /* bad argument to system call */ 267 #define SIGPIPE 13 /* write on a pipe with no one to read it */ 268 #define SIGALRM 14 /* alarm clock */ 269 #define SIGTERM 15 /* software termination signal from kill */ 270 271 #if defined(__rtems__) 272 #define SIGUSR1 16 /* reserved as application defined signal 1 */ 273 #define SIGUSR2 17 /* reserved as application defined signal 2 */ 274 275 #define __SIGFIRSTNOTRT SIGHUP 276 #define __SIGLASTNOTRT SIGUSR2 277 278 /* RTEMS does not support job control, hence no Job Control Signals are 279 defined per P1003.1b-1993, p. 60-61. 280 281 RTEMS does not support memory protection, hence no Memory Protection 282 Signals are defined per P1003.1b-1993, p. 60-61. */ 283 284 /* Real-Time Signals Range, P1003.1b-1993, p. 61 285 NOTE: By P1003.1b-1993, this should be at least RTSIG_MAX 286 (which is a minimum of 8) signals. 287 */ 288 289 #define SIGRTMIN 18 290 #define SIGRTMAX 32 291 292 #elif defined(__svr4__) 293 /* svr4 specifics. different signals above 15, and sigaction. */ 294 #define SIGUSR1 16 295 #define SIGUSR2 17 296 #define SIGCLD 18 297 #define SIGPWR 19 298 #define SIGWINCH 20 299 #define SIGPOLL 22 /* 20 for x.out binaries!!!! */ 300 #define SIGSTOP 23 /* sendable stop signal not from tty */ 301 #define SIGTSTP 24 /* stop signal from tty */ 302 #define SIGCONT 25 /* continue a stopped process */ 303 #define SIGTTIN 26 /* to readers pgrp upon background tty read */ 304 #define SIGTTOU 27 /* like TTIN for output if (tp->t_local<OSTOP) */ 305 #define NSIG 28 306 #else 307 #define SIGURG 16 /* urgent condition on IO channel */ 308 #define SIGSTOP 17 /* sendable stop signal not from tty */ 309 #define SIGTSTP 18 /* stop signal from tty */ 310 #define SIGCONT 19 /* continue a stopped process */ 311 #define SIGCHLD 20 /* to parent on child stop or exit */ 312 #define SIGCLD 20 /* System V name for SIGCHLD */ 313 #define SIGTTIN 21 /* to readers pgrp upon background tty read */ 314 #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ 315 #define SIGIO 23 /* input/output possible signal */ 316 #define SIGPOLL SIGIO /* System V name for SIGIO */ 317 #define SIGXCPU 24 /* exceeded CPU time limit */ 318 #define SIGXFSZ 25 /* exceeded file size limit */ 319 #define SIGVTALRM 26 /* virtual time alarm */ 320 #define SIGPROF 27 /* profiling time alarm */ 321 #define SIGWINCH 28 /* window changed */ 322 #define SIGLOST 29 /* resource lost (eg, record-lock lost) */ 323 #define SIGUSR1 30 /* user defined signal 1 */ 324 #define SIGUSR2 31 /* user defined signal 2 */ 325 #define NSIG 32 /* signal 0 implied */ 326 #endif 327 #endif 328 329 #ifdef __cplusplus 330 } 331 #endif 332 #endif /* _SYS_SIGNAL_H */ |