2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
24 #include "pmgtprivate.h"
26 /* Implements native-signal redirection. Basically, NT generated signals
27 * are caught and passed through to the signal functions implemented by
28 * this process management library.
30 * Note that signals are passed through by name, since procmgmt.h can't
31 * be included here (given that signal(), raise(), etc. are redefined).
35 /* Program must have FP code to trap SIGFPE; MS suggests the following def. */
36 static volatile double dummyDouble = 0.0f;
40 * NativeSignalHandler() -- handles (redirects) NT-generated signals.
43 NativeSignalHandler(int signo)
45 const char *signame = NULL;
48 /* Reinstall signal handler for signo; no reliable signals on NT */
49 (void) signal(signo, NativeSignalHandler);
51 /* NT defines few signals, and doesn't really generate all of these */
72 /* unexpect signo value */
77 if (signame != NULL) {
78 /* Redirect NT signal into process management library */
79 if (pmgt_SignalRaiseLocalByName(signame, &libSigno) == 0 &&
81 /* SIGABRT is a special case. It is generated by NT when abort()
82 * is called. Upon returning from the signal handler, abort()
83 * will terminate the process with an exit code of 3. In order
84 * to make an understandable termination status available to the
85 * process management library's waitpid() function, we exit
86 * the process here with a more appropriate exit code.
88 ExitProcess(PMGT_SIGSTATUS_ENCODE(libSigno));
95 * pmgt_RedirectNativeSignals() -- initialize native signal redirection.
98 pmgt_RedirectNativeSignals(void)
100 if (signal(SIGINT, NativeSignalHandler) == SIG_ERR ||
101 signal(SIGILL, NativeSignalHandler) == SIG_ERR ||
102 signal(SIGFPE, NativeSignalHandler) == SIG_ERR ||
103 signal(SIGSEGV, NativeSignalHandler) == SIG_ERR ||
104 signal(SIGTERM, NativeSignalHandler) == SIG_ERR ||
105 signal(SIGABRT, NativeSignalHandler) == SIG_ERR) {