1 /* Copyright (C) 1998 Transarc Corporation. All Rights Reserved.
15 #include "pmgtprivate.h"
17 /* Implements native-signal redirection. Basically, NT generated signals
18 * are caught and passed through to the signal functions implemented by
19 * this process management library.
21 * Note that signals are passed through by name, since procmgmt.h can't
22 * be included here (given that signal(), raise(), etc. are redefined).
26 /* Program must have FP code to trap SIGFPE; MS suggests the following def. */
27 static volatile double dummyDouble = 0.0f;
31 * NativeSignalHandler() -- handles (redirects) NT-generated signals.
34 NativeSignalHandler(int signo)
36 const char *signame = NULL;
39 /* Reinstall signal handler for signo; no reliable signals on NT */
40 (void) signal(signo, NativeSignalHandler);
42 /* NT defines few signals, and doesn't really generate all of these */
63 /* unexpect signo value */
68 if (signame != NULL) {
69 /* Redirect NT signal into process management library */
70 if (pmgt_SignalRaiseLocalByName(signame, &libSigno) == 0 &&
72 /* SIGABRT is a special case. It is generated by NT when abort()
73 * is called. Upon returning from the signal handler, abort()
74 * will terminate the process with an exit code of 3. In order
75 * to make an understandable termination status available to the
76 * process management library's waitpid() function, we exit
77 * the process here with a more appropriate exit code.
79 ExitProcess(PMGT_SIGSTATUS_ENCODE(libSigno));
86 * pmgt_RedirectNativeSignals() -- initialize native signal redirection.
89 pmgt_RedirectNativeSignals(void)
91 if (signal(SIGINT, NativeSignalHandler) == SIG_ERR ||
92 signal(SIGILL, NativeSignalHandler) == SIG_ERR ||
93 signal(SIGFPE, NativeSignalHandler) == SIG_ERR ||
94 signal(SIGSEGV, NativeSignalHandler) == SIG_ERR ||
95 signal(SIGTERM, NativeSignalHandler) == SIG_ERR ||
96 signal(SIGABRT, NativeSignalHandler) == SIG_ERR) {