[3897] | 1 | /* $Id: signal.h 3897 2014-06-29 19:36:55Z bird $ */
|
---|
[1574] | 2 | /** @file
|
---|
| 3 | *
|
---|
| 4 | * BSD compatible.
|
---|
| 5 | *
|
---|
| 6 | *
|
---|
| 7 | * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
|
---|
| 8 | *
|
---|
| 9 | *
|
---|
| 10 | * This file is part of InnoTek LIBC.
|
---|
| 11 | *
|
---|
| 12 | * InnoTek LIBC is free software; you can redistribute it and/or modify
|
---|
| 13 | * it under the terms of the GNU Lesser General Public License as published
|
---|
| 14 | * by the Free Software Foundation; either version 2 of the License, or
|
---|
| 15 | * (at your option) any later version.
|
---|
| 16 | *
|
---|
| 17 | * InnoTek LIBC is distributed in the hope that it will be useful,
|
---|
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | * GNU Lesser General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU Lesser General Public License
|
---|
| 23 | * along with InnoTek LIBC; if not, write to the Free Software
|
---|
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 25 | *
|
---|
| 26 | */
|
---|
| 27 |
|
---|
| 28 |
|
---|
| 29 | #ifndef _SYS_SIGNAL_H_
|
---|
| 30 | #define _SYS_SIGNAL_H_
|
---|
| 31 |
|
---|
| 32 | /*******************************************************************************
|
---|
| 33 | * Header Files *
|
---|
| 34 | *******************************************************************************/
|
---|
| 35 | #include <sys/cdefs.h>
|
---|
| 36 | #include <sys/_types.h>
|
---|
| 37 | #include <machine/signal.h>
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 | /*******************************************************************************
|
---|
| 41 | * Defined Constants And Macros *
|
---|
| 42 | *******************************************************************************/
|
---|
| 43 | /** @defgroup sys_signal_h_signo Signal numbers.
|
---|
| 44 | * @{
|
---|
| 45 | */
|
---|
| 46 | #if __XSI_VISIBLE || __POSIX_VISIBLE
|
---|
| 47 | #define SIGHUP 1 /** POSIX: Hangup */
|
---|
| 48 | #endif
|
---|
| 49 | #define SIGINT 2 /** ANSI: Interrupt (Ctrl-C) */
|
---|
| 50 | #if __XSI_VISIBLE || __POSIX_VISIBLE
|
---|
| 51 | #define SIGQUIT 3 /** POSIX: Quit */
|
---|
| 52 | #endif
|
---|
| 53 | #define SIGILL 4 /** ANSI: Illegal instruction */
|
---|
[1617] | 54 | #if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
|
---|
[1574] | 55 | #define SIGTRAP 5 /** POSIX: Single step (debugging) */
|
---|
| 56 | #endif
|
---|
| 57 | #define SIGABRT 6 /** ANSI: abort () */
|
---|
| 58 | #if __BSD_VISIBLE
|
---|
| 59 | #define SIGIOT SIGABRT /** BSD 4.2 */
|
---|
| 60 | #define SIGEMT 7 /** BSD: EMT instruction */
|
---|
| 61 | #endif
|
---|
| 62 | #define SIGFPE 8 /** ANSI: Floating point */
|
---|
| 63 | #if __XSI_VISIBLE || __POSIX_VISIBLE
|
---|
| 64 | #define SIGKILL 9 /** POSIX: Kill process */
|
---|
| 65 | #endif
|
---|
| 66 | #if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
|
---|
| 67 | #define SIGBUS 10 /** BSD 4.2: Bus error */
|
---|
| 68 | #endif
|
---|
| 69 | #define SIGSEGV 11 /** ANSI: Segmentation fault */
|
---|
[1617] | 70 | #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112
|
---|
[1574] | 71 | #define SIGSYS 12 /** Invalid argument to system call */
|
---|
| 72 | #endif
|
---|
| 73 | #if __XSI_VISIBLE || __POSIX_VISIBLE
|
---|
| 74 | #define SIGPIPE 13 /** POSIX: Broken pipe. */
|
---|
| 75 | #define SIGALRM 14 /** POSIX: Alarm. */
|
---|
| 76 | #endif
|
---|
| 77 | #define SIGTERM 15 /** ANSI: Termination, process killed */
|
---|
| 78 | #if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
|
---|
| 79 | #define SIGURG 16 /** POSIX/BSD: urgent condition on IO channel */
|
---|
| 80 | #endif
|
---|
| 81 | #if __XSI_VISIBLE || __POSIX_VISIBLE
|
---|
| 82 | #define SIGSTOP 17 /** POSIX: Sendable stop signal not from tty. unblockable. */
|
---|
| 83 | #define SIGTSTP 18 /** POSIX: Stop signal from tty. */
|
---|
| 84 | #define SIGCONT 19 /** POSIX: Continue a stopped process. */
|
---|
| 85 | #define SIGCHLD 20 /** POSIX: Death or stop of a child process. (EMX: 18) */
|
---|
| 86 | #define SIGCLD SIGCHLD /** System V */
|
---|
| 87 | #define SIGTTIN 21 /** POSIX: To readers pgrp upon background tty read. */
|
---|
| 88 | #define SIGTTOU 22 /** POSIX: To readers pgrp upon background tty write. */
|
---|
| 89 | #endif
|
---|
| 90 | #if __BSD_VISIBLE
|
---|
| 91 | #define SIGIO 23 /** BSD: Input/output possible signal. */
|
---|
| 92 | #endif
|
---|
| 93 | #if __XSI_VISIBLE
|
---|
[1617] | 94 | #define SIGPOLL 23 /** ??: Input/output possible signal. (Same as SIGIO.) */
|
---|
| 95 | #endif
|
---|
| 96 | #if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
|
---|
[1574] | 97 | #define SIGXCPU 24 /** BSD 4.2: Exceeded CPU time limit. */
|
---|
| 98 | #define SIGXFSZ 25 /** BSD 4.2: Exceeded file size limit. */
|
---|
[1617] | 99 | #endif
|
---|
| 100 | #if __XSI_VISIBLE
|
---|
[1574] | 101 | #define SIGVTALRM 26 /** BSD 4.2: Virtual time alarm. */
|
---|
[1617] | 102 | #endif
|
---|
| 103 | #if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
|
---|
[1574] | 104 | #define SIGPROF 27 /** BSD 4.2: Profiling time alarm. */
|
---|
| 105 | #endif
|
---|
| 106 | #if __BSD_VISIBLE
|
---|
| 107 | #define SIGWINCH 28 /** BSD 4.3: Window size change (not implemented). */
|
---|
| 108 | #define SIGINFO 29 /** BSD 4.3: Information request. */
|
---|
| 109 | #endif
|
---|
| 110 | #if __XSI_VISIBLE || __POSIX_VISIBLE
|
---|
| 111 | #define SIGUSR1 30 /** POSIX: User-defined signal #1 */
|
---|
| 112 | #define SIGUSR2 31 /** POSIX: User-defined signal #2 */
|
---|
| 113 | #endif
|
---|
| 114 | #define SIGBREAK 32 /** OS/2: Break (Ctrl-Break). (EMX: 21) */
|
---|
| 115 |
|
---|
| 116 | #define SIGRTMIN 33 /** First real time signal. */
|
---|
| 117 | #define SIGRTMAX 63 /** Last real time signal (inclusive) */
|
---|
[2305] | 118 | #if __BSD_VISIBLE || defined __USE_MISC
|
---|
[2107] | 119 | #define _NSIG (SIGRTMAX + 1) /** Number of signals (exclusive). Valid range is 1 to (_NSIG-1). */
|
---|
| 120 | #define NSIG _NSIG /** See _NSIG. */
|
---|
| 121 | #define MAXSIG SIGRTMAX /** Max signal number, includsive. (Sun) */
|
---|
| 122 | #endif
|
---|
[1574] | 123 | /** @} */
|
---|
| 124 |
|
---|
| 125 |
|
---|
| 126 | /** @defgroup sys_signal_h_sighnd Fake Signal Functions
|
---|
| 127 | * @{
|
---|
| 128 | */
|
---|
[2216] | 129 | #define SIG_ERR ((__sighandler_t *)-1) /** Failure. */
|
---|
| 130 | #define SIG_DFL ((__sighandler_t *)0) /** Default action. */
|
---|
| 131 | #define SIG_IGN ((__sighandler_t *)1) /** Ignore signal. */
|
---|
[1574] | 132 | /* 2 is reserved for BSD internal use */
|
---|
| 133 | #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 /** @todo check specs on SIG_HOLD. */
|
---|
[2216] | 134 | #define SIG_HOLD ((__sighandler_t *)3)
|
---|
[1574] | 135 | #endif
|
---|
| 136 | #ifdef __BSD_VISIBLE
|
---|
[2216] | 137 | #define SIG_ACK ((__sighandler_t *)4) /** OS/2: Acknowledge a signal. */
|
---|
[1574] | 138 | #endif
|
---|
| 139 | /** @} */
|
---|
| 140 |
|
---|
| 141 |
|
---|
| 142 | /** @defgroup sys_signal_h_sigev Signal Event Notification Types.
|
---|
| 143 | * See struct sigevent.
|
---|
| 144 | * @{
|
---|
| 145 | */
|
---|
| 146 | #define SIGEV_NONE 0 /* No async notification */
|
---|
| 147 | #define SIGEV_SIGNAL 1 /* Generate a queued signal */
|
---|
| 148 | #define SIGEV_THREAD 2 /* Deliver via thread creation. */
|
---|
| 149 | /** @} */
|
---|
| 150 |
|
---|
| 151 |
|
---|
| 152 | /** @defgroup sys_signal_h_sigaction_flags Signal Action Flags.
|
---|
| 153 | * @{
|
---|
| 154 | */
|
---|
| 155 | #if __XSI_VISIBLE
|
---|
| 156 | /** Take signal on a registerd stack_t. */
|
---|
| 157 | #define SA_ONSTACK 0x00000001
|
---|
[1615] | 158 | /** Restart system call on signal return. */
|
---|
[1574] | 159 | #define SA_RESTART 0x00000002
|
---|
| 160 | /** Reset signal handler to SIG_DFL when deliving the signal. */
|
---|
| 161 | #define SA_RESETHAND 0x00000004
|
---|
| 162 | /** Don't mask the signal which is being delivered. */
|
---|
| 163 | #define SA_NODEFER 0x00000010
|
---|
[1630] | 164 | /** Don't keep zombies around for wait*(). */
|
---|
[1574] | 165 | #define SA_NOCLDWAIT 0x00000020
|
---|
| 166 | /** Signal the handler with the full set of arguments. */
|
---|
| 167 | #define SA_SIGINFO 0x00000040
|
---|
| 168 | #endif
|
---|
| 169 | #if __XSI_VISIBLE || __POSIX_VISIBLE
|
---|
| 170 | /** Do not generate SIGCHLD on child stop. */
|
---|
| 171 | #define SA_NOCLDSTOP 0x00000008
|
---|
| 172 | #endif
|
---|
| 173 | /** Block the signal (OS/2 legacy mode). */
|
---|
| 174 | #define SA_ACK 0x10000000
|
---|
| 175 | /** EMX compatibility. */
|
---|
| 176 | #define SA_SYSV SA_RESETHAND
|
---|
| 177 | /** @} */
|
---|
| 178 |
|
---|
| 179 |
|
---|
| 180 | #if __BSD_VISIBLE
|
---|
| 181 | /** #defgroup sys_signal_h_sigval_flags Signal Value Flags.
|
---|
| 182 | * BSD 4.3 compatibility.
|
---|
| 183 | * @{
|
---|
| 184 | */
|
---|
| 185 | #define SV_ONSTACK SA_ONSTACK
|
---|
| 186 | /** opposite sense. */
|
---|
| 187 | #define SV_INTERRUPT SA_RESTART
|
---|
| 188 | #define SV_RESETHAND SA_RESETHAND
|
---|
| 189 | #define SV_NODEFER SA_NODEFER
|
---|
| 190 | #define SV_NOCLDSTOP SA_NOCLDSTOP
|
---|
| 191 | #define SV_SIGINFO SA_SIGINFO
|
---|
| 192 | /** @} */
|
---|
| 193 | #endif
|
---|
| 194 |
|
---|
| 195 |
|
---|
| 196 | /** @defgroup sys_signal_h_stack_t_flags Signal Stack Flags. (ss_flags)
|
---|
| 197 | * @{
|
---|
| 198 | */
|
---|
[1617] | 199 | /** Current on alternative stack. */
|
---|
[1574] | 200 | #define SS_ONSTACK 0x00000001
|
---|
| 201 | /** Do not take signal on alternate stack. */
|
---|
| 202 | #define SS_DISABLE 0x00000004
|
---|
| 203 | /** @} */
|
---|
| 204 | /** Recommended size for an alternate signal stack. (See stack_t) */
|
---|
| 205 | #define SIGSTKSZ (0x10000)
|
---|
| 206 |
|
---|
| 207 |
|
---|
| 208 |
|
---|
| 209 | #if __BSD_VISIBLE || __POSIX_VISIBLE > 0 && __POSIX_VISIBLE <= 200112
|
---|
| 210 | /** Convert signo to a signal mask for use with sigblock(). */
|
---|
| 211 | #define sigmask(signo) (1 << ((signo) - 1))
|
---|
| 212 | #endif
|
---|
| 213 |
|
---|
| 214 | #if __BSD_VISIBLE
|
---|
| 215 | #define BADSIG SIG_ERR
|
---|
| 216 | #endif
|
---|
| 217 |
|
---|
| 218 | #if __POSIX_VISIBLE || __XSI_VISIBLE
|
---|
| 219 | /*
|
---|
| 220 | * Flags for sigprocmask:
|
---|
| 221 | */
|
---|
| 222 | /** @defgroup sys_signal_h_sigprocmask_flags Flags for sigprocmask().
|
---|
| 223 | * @{
|
---|
| 224 | */
|
---|
| 225 | /** Block specified signal set. */
|
---|
| 226 | #define SIG_BLOCK 1
|
---|
| 227 | /** Unblock specified signal set. */
|
---|
| 228 | #define SIG_UNBLOCK 2
|
---|
| 229 | /** Set specified signal set. */
|
---|
| 230 | #define SIG_SETMASK 3
|
---|
| 231 | #endif
|
---|
| 232 |
|
---|
| 233 |
|
---|
| 234 |
|
---|
| 235 | /** @defgroup sys_signal_h_si_code siginfo_t.si_code values.
|
---|
| 236 | * @{
|
---|
| 237 | */
|
---|
| 238 |
|
---|
| 239 | /** @defgroup sys_signal_h_si_code_sigill siginfo_t.si_code values - SIGILL
|
---|
| 240 | * @{ */
|
---|
| 241 | /** Illegal opcode. */
|
---|
| 242 | #define ILL_ILLOPC 0x80001001
|
---|
| 243 | /** Illegal operand. */
|
---|
| 244 | #define ILL_ILLOPN 0x80001002
|
---|
| 245 | /** Illegal addressing mode. */
|
---|
| 246 | #define ILL_ILLADR 0x80001003
|
---|
| 247 | /** Illegal trap. */
|
---|
| 248 | #define ILL_ILLTRP 0x80001004
|
---|
| 249 | /** Privileged opcode. */
|
---|
| 250 | #define ILL_PRVOPC 0x80001005
|
---|
| 251 | /** Privileged register. */
|
---|
| 252 | #define ILL_PRVREG 0x80001006
|
---|
| 253 | /** Coprocessor error. */
|
---|
| 254 | #define ILL_COPROC 0x80001007
|
---|
| 255 | /** Internal stack error. */
|
---|
| 256 | #define ILL_BADSTK 0x80001008
|
---|
| 257 | /** @} */
|
---|
| 258 |
|
---|
| 259 |
|
---|
| 260 | /** @defgroup sys_signal_h_si_code_sigfpe siginfo_t.si_code values - SIGILL
|
---|
| 261 | * @{ */
|
---|
| 262 | /** see machine/trap.h. */
|
---|
| 263 | /** @} */
|
---|
| 264 |
|
---|
| 265 |
|
---|
| 266 | /** @defgroup sys_signal_h_si_code_sigsegv siginfo_t.si_code values - SIGSEGV
|
---|
| 267 | * @{ */
|
---|
| 268 | /** Address not mapped to object. */
|
---|
| 269 | #define SEGV_MAPERR 0x80003001
|
---|
| 270 | /** Invalid permissions for mapped object. */
|
---|
| 271 | #define SEGV_ACCERR 0x80003002
|
---|
| 272 | /** @} */
|
---|
| 273 |
|
---|
| 274 |
|
---|
| 275 | /** @defgroup sys_signal_h_si_code_sigbus siginfo_t.si_code values - SIGBUS
|
---|
| 276 | * @{ */
|
---|
| 277 | /** Invalid address alignment. */
|
---|
| 278 | #define BUS_ADRALN 0x80004001
|
---|
| 279 | /** Nonexistent physical address. */
|
---|
| 280 | #define BUS_ADRERR 0x80004002
|
---|
| 281 | /** Object-specific hardware error. */
|
---|
| 282 | #define BUS_OBJERR 0x80004003
|
---|
| 283 | /** @} */
|
---|
| 284 |
|
---|
| 285 |
|
---|
| 286 | /** @defgroup sys_signal_h_si_code_sigtrap siginfo_t.si_code values - SIGTRAP
|
---|
| 287 | * @{ */
|
---|
| 288 | /** Process breakpoint. */
|
---|
| 289 | #define TRAP_BRKPT 0x80005001
|
---|
| 290 | /** Process trace trap. */
|
---|
| 291 | #define TRAP_TRACE 0x80005002
|
---|
| 292 | /** @} */
|
---|
| 293 |
|
---|
| 294 |
|
---|
| 295 | /** @defgroup sys_signal_h_si_code_sigchild siginfo_t.si_code values - SIGCHLD
|
---|
| 296 | * @{ */
|
---|
| 297 | /** Child has exited. */
|
---|
| 298 | #define CLD_EXITED 0x80006001
|
---|
| 299 | /** Child has terminated abnormally and did not create a core file. */
|
---|
| 300 | #define CLD_KILLED 0x80006002
|
---|
| 301 | /** Child has terminated abnormally and created a core file. */
|
---|
| 302 | #define CLD_DUMPED 0x80006003
|
---|
| 303 | /** Traced child has trapped. */
|
---|
| 304 | #define CLD_TRAPPED 0x80006004
|
---|
| 305 | /** Child has stopped. */
|
---|
| 306 | #define CLD_STOPPED 0x80006005
|
---|
| 307 | /** Stopped child has continued. */
|
---|
| 308 | #define CLD_CONTINUED 0x80006006
|
---|
| 309 | /** @} */
|
---|
| 310 |
|
---|
| 311 |
|
---|
| 312 | /** @defgroup sys_signal_h_si_code_sigpoll siginfo_t.si_code values - SIGPOLL
|
---|
| 313 | * @{ */
|
---|
| 314 | /** Data input available. */
|
---|
| 315 | #define POLL_IN 0x80007001
|
---|
| 316 | /** Output buffers available. */
|
---|
| 317 | #define POLL_OUT 0x80007002
|
---|
| 318 | /** Input message available. */
|
---|
| 319 | #define POLL_MSG 0x80007003
|
---|
| 320 | /** I/O error. */
|
---|
| 321 | #define POLL_ERR 0x80007004
|
---|
| 322 | /** High priority input available. */
|
---|
| 323 | #define POLL_PRI 0x80007005
|
---|
| 324 | /** Device disconnected. */
|
---|
| 325 | #define POLL_HUP 0x80007006
|
---|
| 326 | /** @} */
|
---|
| 327 |
|
---|
| 328 |
|
---|
| 329 | /** @defgroup sys_signal_h_siginfo_codes Signal Info Codes (si_code).
|
---|
| 330 | * @{ */
|
---|
| 331 | #if __POSIX_VISIBLE || __XSI_VISIBLE
|
---|
| 332 | /** Sent by kill() or raise(). */
|
---|
| 333 | #define SI_USER 0x00010001
|
---|
| 334 | /** Sent by sigqueue(). */
|
---|
| 335 | #define SI_QUEUE 0x00010002
|
---|
| 336 | /** Sent cause a timer expired. */
|
---|
| 337 | #define SI_TIMER 0x00010003
|
---|
| 338 | /** Sent upon AIO completion. */
|
---|
| 339 | #define SI_ASYNCIO 0x00010004
|
---|
| 340 | /** Sent upon real time mesq state change. */
|
---|
| 341 | #define SI_MESGQ 0x00010005
|
---|
| 342 | #endif
|
---|
| 343 | #if __BSD_VISIBLE
|
---|
| 344 | /** No idea. */
|
---|
| 345 | #define SI_UNDEFINED 0x00000000
|
---|
| 346 | #endif
|
---|
| 347 | /** @} */
|
---|
| 348 |
|
---|
| 349 | /** @} */
|
---|
| 350 |
|
---|
| 351 |
|
---|
| 352 | /*******************************************************************************
|
---|
| 353 | * Structures and Typedefs *
|
---|
| 354 | *******************************************************************************/
|
---|
| 355 | #if __POSIX_VISIBLE || __XSI_VISIBLE
|
---|
| 356 | #ifndef _SIGSET_T_DECLARED
|
---|
| 357 | #define _SIGSET_T_DECLARED
|
---|
| 358 | /** Signal set. */
|
---|
| 359 | typedef __sigset_t sigset_t;
|
---|
| 360 | #endif
|
---|
| 361 | #endif
|
---|
| 362 |
|
---|
| 363 |
|
---|
| 364 | #if __POSIX_VISIBLE >= 199309 || __XSI_VISIBLE >= 500
|
---|
| 365 | /** Type for a value associated with a signal. */
|
---|
| 366 | typedef union sigval
|
---|
| 367 | {
|
---|
[1624] | 368 | /** Interger value. */
|
---|
| 369 | int sival_int;
|
---|
| 370 | /** Pointer value. */
|
---|
| 371 | void *sival_ptr;
|
---|
| 372 | /** FreeBSD names - probably a typo in the FreeBSD, but anyway.
|
---|
| 373 | * @{ */
|
---|
[1574] | 374 | int sigval_int;
|
---|
| 375 | void *sigval_ptr;
|
---|
[1624] | 376 | /** @} */
|
---|
[1574] | 377 | } sigval_t;
|
---|
| 378 | #endif
|
---|
| 379 |
|
---|
| 380 |
|
---|
| 381 | #if __POSIX_VISIBLE >= 199309
|
---|
| 382 | /** Signal event. */
|
---|
| 383 | typedef struct sigevent
|
---|
| 384 | {
|
---|
| 385 | /** Notification type. */
|
---|
| 386 | int sigev_notify;
|
---|
| 387 | /** Signal number. */
|
---|
| 388 | int sigev_signo;
|
---|
| 389 | /** Signal value. */
|
---|
| 390 | union sigval sigev_value;
|
---|
| 391 | /** Thread Function. */
|
---|
| 392 | void (*sigev_notify_function)(sigval_t);
|
---|
| 393 | /** Thread Attributes. */
|
---|
| 394 | void *sigev_notify_attributes;
|
---|
| 395 | } sigevent_t;
|
---|
| 396 | #endif
|
---|
| 397 |
|
---|
| 398 |
|
---|
| 399 | #if __XSI_VISIBLE || __POSIX_VISIBLE >= 199309
|
---|
| 400 | /**
|
---|
| 401 | * Signal info.
|
---|
| 402 | */
|
---|
| 403 | typedef struct __siginfo
|
---|
| 404 | {
|
---|
| 405 | /** Signal number. */
|
---|
| 406 | int si_signo;
|
---|
| 407 | /** Associated errno. */
|
---|
| 408 | int si_errno;
|
---|
| 409 | /** Signal code. (See SI_* and FPE_* macros.) */
|
---|
| 410 | int si_code;
|
---|
[1630] | 411 | /** LIBC Extension: Timestamp when the signal was generated. */
|
---|
[1574] | 412 | unsigned si_timestamp;
|
---|
[1630] | 413 | /** LIBC Extension: Flags. __LIBC_SI_* */
|
---|
[1615] | 414 | unsigned si_flags;
|
---|
[1574] | 415 | /** Process sending the signal. */
|
---|
| 416 | __pid_t si_pid;
|
---|
[1630] | 417 | /** LIBC Extension: the program group of the sender. */
|
---|
| 418 | unsigned si_pgrp;
|
---|
| 419 | /** LIBC Extension: Thread sending the signal. */
|
---|
[1574] | 420 | unsigned si_tid;
|
---|
[1630] | 421 | /** User sending the signal (real uid). */
|
---|
[1574] | 422 | __uid_t si_uid;
|
---|
| 423 | /** Exit value. (SIGCHLD) */
|
---|
| 424 | int si_status;
|
---|
| 425 | /** Pointer to the faulting instruction or memory reference. (SIGSEGV, SIGILL, SIGFPE, SIGBUS) */
|
---|
| 426 | void *si_addr;
|
---|
| 427 | /** Signal value. */
|
---|
| 428 | union sigval si_value;
|
---|
| 429 | /** Band event for SIGPOLL. */
|
---|
| 430 | long si_band;
|
---|
| 431 | /** Filehandle for SIGPOLL. */
|
---|
| 432 | int si_fd;
|
---|
| 433 | /** Reserve a little bit for future usage. */
|
---|
[1630] | 434 | unsigned auReserved[6];
|
---|
[1574] | 435 | } siginfo_t;
|
---|
[1615] | 436 |
|
---|
| 437 | #ifdef __BSD_VISIBLE
|
---|
| 438 | /** Signals LIBC flags.
|
---|
| 439 | * @{ */
|
---|
| 440 | /** If set the signal was queue. */
|
---|
[1630] | 441 | #define __LIBC_SI_QUEUED 0x00000001
|
---|
[1617] | 442 | /** Internal signal generated by LIBC. */
|
---|
[1630] | 443 | #define __LIBC_SI_INTERNAL 0x00000002
|
---|
| 444 | /** Don't notify the child wait facilities. (Signal origins there.) */
|
---|
| 445 | #define __LIBC_SI_NO_NOTIFY_CHILD 0x00000004
|
---|
[1615] | 446 | /** @} */
|
---|
[1574] | 447 | #endif
|
---|
[1615] | 448 | #endif
|
---|
[1574] | 449 |
|
---|
[2216] | 450 | /** ANSI C signals handler. */
|
---|
| 451 | typedef void __sighandler_t(int);
|
---|
| 452 | /** POSIX Signal info handler. */
|
---|
| 453 | typedef void __siginfohandler_t(int, struct __siginfo *, void *);
|
---|
[1574] | 454 |
|
---|
[2216] | 455 | #ifdef __BSD_VISIBLE
|
---|
| 456 | /** BSD 4.4 type. */
|
---|
| 457 | typedef __sighandler_t *sig_t;
|
---|
| 458 | #endif
|
---|
| 459 | #ifdef __USE_GNU
|
---|
| 460 | /** GLIBC makes this symbol available */
|
---|
| 461 | typedef __sighandler_t *sighandler_t;
|
---|
| 462 | #endif
|
---|
| 463 |
|
---|
[1574] | 464 | #if __POSIX_VISIBLE || __XSI_VISIBLE
|
---|
| 465 | struct __siginfo;
|
---|
| 466 |
|
---|
| 467 | /** Signal action structure for sigaction(). */
|
---|
| 468 | struct sigaction
|
---|
| 469 | {
|
---|
| 470 | /** Two handler prototypes, __sa_handler is the exposed one,
|
---|
| 471 | * while __sa_sigaction is the one used internally. The two extra
|
---|
| 472 | * arguments will not cause any trouble because of the nature of
|
---|
| 473 | * __cdecl on i386.
|
---|
| 474 | */
|
---|
| 475 | union
|
---|
| 476 | {
|
---|
| 477 | /** New style handler. First arg is signal number, second is signal
|
---|
| 478 | * info, third is signal specific (I think). */
|
---|
[2216] | 479 | __siginfohandler_t *__sa_sigaction;
|
---|
[1574] | 480 | /** Old style handler. First arg is signal number. */
|
---|
[2216] | 481 | __sighandler_t *__sa_handler;
|
---|
[1574] | 482 | } __sigaction_u;
|
---|
| 483 | /** Signal mask to apply when executing the action. */
|
---|
| 484 | sigset_t sa_mask;
|
---|
| 485 | /** Signal action flags. (See SA_* macros.) */
|
---|
| 486 | int sa_flags;
|
---|
| 487 | };
|
---|
| 488 | #define sa_handler __sigaction_u.__sa_handler
|
---|
[1617] | 489 | #define sa_sigaction __sigaction_u.__sa_sigaction
|
---|
[1574] | 490 | #endif
|
---|
| 491 |
|
---|
| 492 |
|
---|
| 493 | #if __BSD_VISIBLE
|
---|
| 494 | /** BSD 4.3 compatibility.
|
---|
| 495 | * This structure is identical to sigaction.
|
---|
| 496 | */
|
---|
| 497 | struct sigvec
|
---|
| 498 | {
|
---|
| 499 | /** See sa_sigaction in struct sigaction. */
|
---|
[2216] | 500 | __sighandler_t *sv_handler;
|
---|
[1574] | 501 | /** See sa_mask in struct sigaction. */
|
---|
[2216] | 502 | int sv_mask;
|
---|
[1574] | 503 | /** See sa_flags in struct sigaction. */
|
---|
[2216] | 504 | int sv_flags;
|
---|
[1574] | 505 | };
|
---|
| 506 | #define sv_onstack sv_flags
|
---|
| 507 | #endif
|
---|
| 508 |
|
---|
| 509 |
|
---|
| 510 | #if __XSI_VISIBLE
|
---|
| 511 | /*
|
---|
| 512 | * Structure used in sigaltstack call.
|
---|
| 513 | */
|
---|
| 514 | #if __BSD_VISIBLE
|
---|
| 515 | typedef struct sigaltstack
|
---|
| 516 | #else
|
---|
| 517 | typedef struct
|
---|
| 518 | #endif
|
---|
| 519 | {
|
---|
| 520 | /** Stack base pointer. */
|
---|
| 521 | void *ss_sp;
|
---|
| 522 | /** Stack size. */
|
---|
| 523 | __size_t ss_size;
|
---|
| 524 | /** Flags. (SS_DISABLE and/or SS_ONSTACK) */
|
---|
| 525 | int ss_flags;
|
---|
| 526 | } stack_t;
|
---|
| 527 | #endif
|
---|
| 528 |
|
---|
| 529 |
|
---|
| 530 | #if __XSI_VISIBLE
|
---|
| 531 | /** Structure for sigstack(). obsolete. */
|
---|
| 532 | struct sigstack
|
---|
| 533 | {
|
---|
| 534 | /** Pointer to stack base. */
|
---|
| 535 | void *ss_sp;
|
---|
| 536 | /** On stack indicator. Non zero if executing on this stack. */
|
---|
| 537 | int ss_onstack;
|
---|
| 538 | };
|
---|
| 539 | #endif
|
---|
| 540 |
|
---|
| 541 |
|
---|
| 542 | /*******************************************************************************
|
---|
[2915] | 543 | * Global Variables *
|
---|
| 544 | *******************************************************************************/
|
---|
| 545 | #if __BSD_VISIBLE
|
---|
| 546 | /** Signal set of the signals which will interrupt system call execution.
|
---|
| 547 | * By default all signals will interrupt syscall execution, since OS/2 can't really
|
---|
| 548 | * restart system calls easily.
|
---|
| 549 | * Update is protected by the signal semaphore, however read access isn't.
|
---|
| 550 | */
|
---|
| 551 | extern sigset_t __libc_gSignalRestartMask;
|
---|
| 552 | #endif
|
---|
| 553 |
|
---|
| 554 |
|
---|
| 555 | /*******************************************************************************
|
---|
[1574] | 556 | * Functions *
|
---|
| 557 | *******************************************************************************/
|
---|
| 558 |
|
---|
| 559 | __BEGIN_DECLS
|
---|
[2216] | 560 | __sighandler_t *signal(int, __sighandler_t *);
|
---|
| 561 | __sighandler_t *bsd_signal(int, __sighandler_t *);
|
---|
| 562 | __sighandler_t *_signal_sysv(int, __sighandler_t *);
|
---|
| 563 | __sighandler_t *_signal_os2(int, __sighandler_t *);
|
---|
[1574] | 564 |
|
---|
| 565 | /** @define __LIBC_SIGNAL_SYSV
|
---|
| 566 | * #define __LIBC_SIGNAL_SYSV to use System V style signal. */
|
---|
| 567 | #ifdef __LIBC_SIGNAL_SYSV
|
---|
[2216] | 568 | static inline __sighandler_t *signal(int iSignalNo, __sighandler_t *pfnHandler)
|
---|
[1574] | 569 | { return _signal_sysv(iSignalNo, pfnHandler); }
|
---|
| 570 | #endif
|
---|
| 571 |
|
---|
| 572 | /** @define __LIBC_SIGNAL_OS2
|
---|
| 573 | * #define __LIBC_SIGNAL_OS2 to use System V style signal. */
|
---|
| 574 | #ifdef __LIBC_SIGNAL_OS2
|
---|
[2216] | 575 | static inline __sighandler_t *signal(int iSignalNo, __sighandler_t *pfnHandler)
|
---|
[1574] | 576 | { return _signal_os2(iSignalNo, pfnHandler); }
|
---|
| 577 | #endif
|
---|
| 578 |
|
---|
| 579 | __END_DECLS
|
---|
| 580 |
|
---|
| 581 |
|
---|
| 582 | #if 0 /** @todo various emx stuff. */
|
---|
| 583 | #define SIGPTRACENOTIFY 128 /* Notification from ptrace() */
|
---|
| 584 | #define SIGTY void
|
---|
| 585 | #endif
|
---|
| 586 |
|
---|
| 587 | #endif /* not _SYS_SIGNAL_H */
|
---|
| 588 |
|
---|