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 <afs/param.h>
20 #include "pmgtprivate.h"
22 /* Implements native-signal redirection. Basically, NT generated signals
23 * are caught and passed through to the signal functions implemented by
24 * this process management library.
26 * Note that signals are passed through by name, since procmgmt.h can't
27 * be included here (given that signal(), raise(), etc. are redefined).
31 /* Program must have FP code to trap SIGFPE; MS suggests the following def. */
32 static volatile double dummyDouble = 0.0f;
36 * NativeSignalHandler() -- handles (redirects) NT-generated signals.
39 NativeSignalHandler(int signo)
41 const char *signame = NULL;
44 /* Reinstall signal handler for signo; no reliable signals on NT */
45 (void) signal(signo, NativeSignalHandler);
47 /* NT defines few signals, and doesn't really generate all of these */
68 /* unexpect signo value */
73 if (signame != NULL) {
74 /* Redirect NT signal into process management library */
75 if (pmgt_SignalRaiseLocalByName(signame, &libSigno) == 0 &&
77 /* SIGABRT is a special case. It is generated by NT when abort()
78 * is called. Upon returning from the signal handler, abort()
79 * will terminate the process with an exit code of 3. In order
80 * to make an understandable termination status available to the
81 * process management library's waitpid() function, we exit
82 * the process here with a more appropriate exit code.
84 ExitProcess(PMGT_SIGSTATUS_ENCODE(libSigno));
91 * pmgt_RedirectNativeSignals() -- initialize native signal redirection.
94 pmgt_RedirectNativeSignals(void)
96 if (signal(SIGINT, NativeSignalHandler) == SIG_ERR ||
97 signal(SIGILL, NativeSignalHandler) == SIG_ERR ||
98 signal(SIGFPE, NativeSignalHandler) == SIG_ERR ||
99 signal(SIGSEGV, NativeSignalHandler) == SIG_ERR ||
100 signal(SIGTERM, NativeSignalHandler) == SIG_ERR ||
101 signal(SIGABRT, NativeSignalHandler) == SIG_ERR) {