Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Wine signal handling |
| 3 | * |
Marcus Meissner | 9faa7d7 | 1999-02-13 17:55:17 +0000 | [diff] [blame] | 4 | * Copyright 1995 Alexandre Julliard |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 7 | #include "config.h" |
| 8 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 9 | #include <stdlib.h> |
Marcus Meissner | 9faa7d7 | 1999-02-13 17:55:17 +0000 | [diff] [blame] | 10 | #include <string.h> |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 11 | #include <signal.h> |
Alexandre Julliard | 234bc24 | 1994-12-10 13:02:28 +0000 | [diff] [blame] | 12 | #include <string.h> |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 13 | #include <errno.h> |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 14 | #include <time.h> |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 15 | #include <setjmp.h> |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 16 | |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 17 | #include <sys/time.h> |
| 18 | #include <sys/timeb.h> |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 19 | #include <sys/types.h> |
| 20 | #include <sys/wait.h> |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 21 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 22 | #ifdef HAVE_SYS_PARAM_H |
| 23 | # include <sys/param.h> |
Alexandre Julliard | 8664b89 | 1996-04-05 14:58:24 +0000 | [diff] [blame] | 24 | #endif |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 25 | #ifdef HAVE_SYSCALL_H |
| 26 | # include <syscall.h> |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 27 | #else |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 28 | # ifdef HAVE_SYS_SYSCALL_H |
| 29 | # include <sys/syscall.h> |
| 30 | # endif |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 31 | #endif |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 32 | |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 33 | #include "winsock.h" |
Marcus Meissner | 9faa7d7 | 1999-02-13 17:55:17 +0000 | [diff] [blame] | 34 | #include "global.h" |
| 35 | #include "options.h" |
| 36 | #include "debugger.h" |
| 37 | #include "miscemu.h" |
| 38 | #include "dosexe.h" |
| 39 | #include "thread.h" |
| 40 | #include "debug.h" |
| 41 | |
| 42 | void (*fnWINE_Debugger)(int,SIGCONTEXT*) = NULL; |
| 43 | void (*ctx_debug_call)(int sig,CONTEXT*ctx)=NULL; |
| 44 | BOOL32 (*fnINSTR_EmulateInstruction)(SIGCONTEXT*ctx)=NULL; |
| 45 | |
| 46 | #ifdef __i386__ |
| 47 | |
| 48 | /* i386 specific faults */ |
| 49 | static const char * const SIGNAL_traps[] = |
| 50 | { |
| 51 | "Division by zero exception", /* 0 */ |
| 52 | "Debug exception", /* 1 */ |
| 53 | "NMI interrupt", /* 2 */ |
| 54 | "Breakpoint exception", /* 3 */ |
| 55 | "Overflow exception", /* 4 */ |
| 56 | "Bound range exception", /* 5 */ |
| 57 | "Invalid opcode exception", /* 6 */ |
| 58 | "Device not available exception", /* 7 */ |
| 59 | "Double fault exception", /* 8 */ |
| 60 | "Coprocessor segment overrun", /* 9 */ |
| 61 | "Invalid TSS exception", /* 10 */ |
| 62 | "Segment not present exception", /* 11 */ |
| 63 | "Stack fault", /* 12 */ |
| 64 | "General protection fault", /* 13 */ |
| 65 | "Page fault", /* 14 */ |
| 66 | "Unknown exception", /* 15 */ |
| 67 | "Floating point exception", /* 16 */ |
| 68 | "Alignment check exception", /* 17 */ |
| 69 | "Machine check exception" /* 18 */ |
| 70 | }; |
| 71 | #define NB_TRAPS (sizeof(SIGNAL_traps) / sizeof(SIGNAL_traps[0])) |
| 72 | #endif |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 73 | |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 74 | /* Linux sigaction function */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 75 | |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 76 | #if defined(linux) && defined(__i386__) |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 77 | /* This is the sigaction structure from the Linux 2.1.20 kernel. */ |
Alexandre Julliard | a11d7b1 | 1998-03-01 20:05:02 +0000 | [diff] [blame] | 78 | #undef sa_handler |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 79 | struct kernel_sigaction |
| 80 | { |
| 81 | void (*sa_handler)(); |
| 82 | unsigned long sa_mask; |
| 83 | unsigned long sa_flags; |
| 84 | void (*sa_restorer)(); |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 85 | }; |
| 86 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 87 | /* Similar to the sigaction function in libc, except it leaves alone the |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 88 | restorer field, which is used to specify the signal stack address */ |
| 89 | static __inline__ int wine_sigaction( int sig, struct kernel_sigaction *new, |
| 90 | struct kernel_sigaction *old ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 91 | { |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 92 | #ifdef __PIC__ |
| 93 | __asm__ __volatile__( "pushl %%ebx\n\t" |
| 94 | "movl %2,%%ebx\n\t" |
| 95 | "int $0x80\n\t" |
| 96 | "popl %%ebx" |
| 97 | : "=a" (sig) |
| 98 | : "0" (SYS_sigaction), |
Marcus Meissner | 4ede296 | 1999-02-21 18:18:42 +0000 | [diff] [blame] | 99 | "r" (sig), |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 100 | "c" (new), |
| 101 | "d" (old) ); |
| 102 | #else |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 103 | __asm__ __volatile__( "int $0x80" |
| 104 | : "=a" (sig) |
| 105 | : "0" (SYS_sigaction), |
| 106 | "b" (sig), |
| 107 | "c" (new), |
| 108 | "d" (old) ); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 109 | #endif /* __PIC__ */ |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 110 | if (sig>=0) |
| 111 | return 0; |
| 112 | errno = -sig; |
| 113 | return -1; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 114 | } |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 115 | #endif /* linux && __i386__ */ |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 116 | |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 117 | /* Signal stack */ |
| 118 | |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 119 | static char SIGNAL_Stack[16384]; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 120 | static sigset_t async_signal_set; |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 121 | |
| 122 | /********************************************************************** |
| 123 | * SIGNAL_child |
| 124 | * |
| 125 | * wait4 terminated child processes |
| 126 | */ |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 127 | static HANDLER_DEF(SIGNAL_child) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 128 | { |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 129 | HANDLER_INIT(); |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 130 | #ifdef HAVE_WAIT4 |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 131 | wait4( 0, NULL, WNOHANG, NULL); |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 132 | #elif defined (HAVE_WAITPID) |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 133 | /* I am sort-of guessing that this is the same as the wait4 call. */ |
| 134 | waitpid (0, NULL, WNOHANG); |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 135 | #else |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 136 | wait(NULL); |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 137 | #endif |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 138 | } |
| 139 | |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 140 | |
| 141 | /********************************************************************** |
| 142 | * SIGNAL_SetHandler |
| 143 | */ |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 144 | void SIGNAL_SetHandler( int sig, void (*func)(), int flags ) |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 145 | { |
| 146 | int ret; |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 147 | |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 148 | #if defined(linux) && defined(__i386__) |
| 149 | |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 150 | struct kernel_sigaction sig_act; |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 151 | sig_act.sa_handler = func; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 152 | sig_act.sa_flags = SA_RESTART | (flags) ? SA_NOMASK : 0; |
| 153 | sig_act.sa_mask = 0; |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 154 | /* Point to the top of the stack, minus 4 just in case, and make |
| 155 | it aligned */ |
| 156 | sig_act.sa_restorer = |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 157 | (void (*)())((int)(SIGNAL_Stack + sizeof(SIGNAL_Stack) - 4) & ~3); |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 158 | ret = wine_sigaction( sig, &sig_act, NULL ); |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 159 | |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 160 | #else /* linux && __i386__ */ |
| 161 | |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 162 | struct sigaction sig_act; |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 163 | sig_act.sa_handler = func; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 164 | sigemptyset( &sig_act.sa_mask ); |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 165 | |
| 166 | # if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 167 | sig_act.sa_flags = SA_ONSTACK; |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 168 | # elif defined (__svr4__) || defined(_SCO_DS) |
Alexandre Julliard | 8bbf818 | 1996-09-13 16:50:47 +0000 | [diff] [blame] | 169 | sig_act.sa_flags = SA_SIGINFO | SA_ONSTACK | SA_RESTART; |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 170 | # elif defined(__EMX__) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 171 | sig_act.sa_flags = 0; /* FIXME: EMX has only SA_ACK and SA_SYSV */ |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 172 | # else |
| 173 | sig_act.sa_flags = 0; |
| 174 | # endif |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 175 | ret = sigaction( sig, &sig_act, NULL ); |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 176 | |
| 177 | #endif /* linux && __i386__ */ |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 178 | |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 179 | if (ret < 0) |
| 180 | { |
| 181 | perror( "sigaction" ); |
| 182 | exit(1); |
| 183 | } |
| 184 | } |
| 185 | |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 186 | extern void stop_wait(int a); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 187 | extern void WINSOCK_sigio(int a); |
Marcus Meissner | ad7538b | 1998-12-14 18:15:10 +0000 | [diff] [blame] | 188 | extern void ASYNC_sigio(int a); |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 189 | |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 190 | |
| 191 | /********************************************************************** |
Marcus Meissner | 9faa7d7 | 1999-02-13 17:55:17 +0000 | [diff] [blame] | 192 | * SIGNAL_MaskAsyncEvents |
| 193 | */ |
| 194 | void SIGNAL_MaskAsyncEvents( BOOL32 flag ) |
| 195 | { |
| 196 | sigprocmask( (flag) ? SIG_BLOCK : SIG_UNBLOCK , &async_signal_set, NULL); |
| 197 | } |
| 198 | |
| 199 | extern void SIGNAL_SetHandler( int sig, void (*func)(), int flags ); |
| 200 | |
| 201 | /********************************************************************** |
| 202 | * SIGNAL_break |
| 203 | * |
| 204 | * Handle Ctrl-C and such |
| 205 | */ |
| 206 | static HANDLER_DEF(SIGNAL_break) |
| 207 | { |
| 208 | HANDLER_INIT(); |
| 209 | if (Options.debug && fnWINE_Debugger) |
| 210 | fnWINE_Debugger( signal, HANDLER_CONTEXT ); /* Enter our debugger */ |
| 211 | else exit(0); |
| 212 | } |
| 213 | |
| 214 | |
| 215 | /********************************************************************** |
| 216 | * SIGNAL_trap |
| 217 | * |
| 218 | * SIGTRAP handler. |
| 219 | */ |
| 220 | static HANDLER_DEF(SIGNAL_trap) |
| 221 | { |
| 222 | HANDLER_INIT(); |
| 223 | if (fnWINE_Debugger) |
| 224 | fnWINE_Debugger( signal, HANDLER_CONTEXT ); /* Enter our debugger */ |
| 225 | } |
| 226 | |
| 227 | |
| 228 | /********************************************************************** |
| 229 | * SIGNAL_fault |
| 230 | * |
| 231 | * Segfault handler. |
| 232 | */ |
| 233 | static HANDLER_DEF(SIGNAL_fault) |
| 234 | { |
| 235 | const char *fault = "Segmentation fault"; |
| 236 | HANDLER_INIT(); |
| 237 | |
| 238 | #ifdef __i386__ |
| 239 | |
| 240 | #if defined(TRAP_sig) && defined(CR2_sig) |
| 241 | if (TRAP_sig(HANDLER_CONTEXT) == 0x0e |
| 242 | && VIRTUAL_HandleFault( (LPVOID)CR2_sig(HANDLER_CONTEXT) )) |
| 243 | return; |
| 244 | #endif |
| 245 | |
| 246 | if (fnINSTR_EmulateInstruction && |
| 247 | fnINSTR_EmulateInstruction( HANDLER_CONTEXT ) |
| 248 | ) |
| 249 | return; |
| 250 | |
| 251 | #ifdef TRAP_sig |
| 252 | if (TRAP_sig( HANDLER_CONTEXT ) < NB_TRAPS) |
| 253 | fault = SIGNAL_traps[TRAP_sig( HANDLER_CONTEXT )]; |
| 254 | #endif |
| 255 | if (IS_SELECTOR_SYSTEM(CS_sig(HANDLER_CONTEXT))) |
| 256 | { |
| 257 | MSG("%s in 32-bit code (0x%08lx).\n", fault, EIP_sig(HANDLER_CONTEXT)); |
| 258 | } |
| 259 | else |
| 260 | { |
| 261 | MSG("%s in 16-bit code (%04x:%04lx).\n", fault, |
| 262 | (WORD)CS_sig(HANDLER_CONTEXT), EIP_sig(HANDLER_CONTEXT) ); |
| 263 | } |
| 264 | #ifdef CR2_sig |
| 265 | MSG("Fault address is 0x%08lx\n",CR2_sig(HANDLER_CONTEXT)); |
| 266 | #endif |
| 267 | #endif |
| 268 | |
| 269 | if (fnWINE_Debugger) |
| 270 | fnWINE_Debugger( signal, HANDLER_CONTEXT ); |
| 271 | } |
| 272 | |
| 273 | |
| 274 | /********************************************************************** |
| 275 | * SIGNAL_InitHandlers |
| 276 | */ |
| 277 | void SIGNAL_InitHandlers(void) |
| 278 | { |
| 279 | SIGNAL_SetHandler( SIGINT, (void (*)())SIGNAL_break, 1); |
| 280 | SIGNAL_SetHandler( SIGSEGV, (void (*)())SIGNAL_fault, 1); |
| 281 | SIGNAL_SetHandler( SIGILL, (void (*)())SIGNAL_fault, 1); |
| 282 | SIGNAL_SetHandler( SIGFPE, (void (*)())SIGNAL_fault, 1); |
| 283 | SIGNAL_SetHandler( SIGTRAP, (void (*)())SIGNAL_trap, 1); /* debugger */ |
| 284 | SIGNAL_SetHandler( SIGHUP, (void (*)())SIGNAL_trap, 1); /* forced break*/ |
| 285 | #ifdef SIGBUS |
| 286 | SIGNAL_SetHandler( SIGBUS, (void (*)())SIGNAL_fault, 1); |
| 287 | #endif |
| 288 | return; |
| 289 | } |
| 290 | |
| 291 | /********************************************************************** |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 292 | * SIGNAL_Init |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 293 | */ |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 294 | BOOL32 SIGNAL_Init(void) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 295 | { |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 296 | #ifdef HAVE_WORKING_SIGALTSTACK |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 297 | struct sigaltstack ss; |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 298 | ss.ss_sp = SIGNAL_Stack; |
| 299 | ss.ss_size = sizeof(SIGNAL_Stack); |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 300 | ss.ss_flags = 0; |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 301 | if (sigaltstack(&ss, NULL) < 0) |
| 302 | { |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 303 | perror("sigstack"); |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 304 | return FALSE; |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 305 | } |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 306 | #endif /* HAVE_SIGALTSTACK */ |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 307 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 308 | sigemptyset(&async_signal_set); |
| 309 | |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 310 | SIGNAL_SetHandler( SIGCHLD, (void (*)())SIGNAL_child, 1); |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 311 | #ifdef CONFIG_IPC |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 312 | sigaddset(&async_signal_set, SIGUSR2); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 313 | SIGNAL_SetHandler( SIGUSR2, (void (*)())stop_wait, 1); /* For IPC */ |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 314 | #endif |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 315 | #ifdef SIGIO |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 316 | sigaddset(&async_signal_set, SIGIO); |
Marcus Meissner | ad7538b | 1998-12-14 18:15:10 +0000 | [diff] [blame] | 317 | /* SIGNAL_SetHandler( SIGIO, (void (*)())WINSOCK_sigio, 0); */ |
| 318 | SIGNAL_SetHandler( SIGIO, (void (*)())ASYNC_sigio, 0); |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 319 | #endif |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 320 | sigaddset(&async_signal_set, SIGALRM); |
| 321 | |
| 322 | /* ignore SIGPIPE so that WINSOCK can get a EPIPE error instead */ |
| 323 | signal (SIGPIPE, SIG_IGN); |
Marcus Meissner | 9faa7d7 | 1999-02-13 17:55:17 +0000 | [diff] [blame] | 324 | SIGNAL_InitHandlers(); |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 325 | return TRUE; |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 326 | } |