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>
23 #include "pmgtprivate.h"
25 /* Implements native-signal redirection. Basically, NT generated signals
26 * are caught and passed through to the signal functions implemented by
27 * this process management library.
29 * Note that signals are passed through by name, since procmgmt.h can't
30 * be included here (given that signal(), raise(), etc. are redefined).
34 /* Program must have FP code to trap SIGFPE; MS suggests the following def. */
35 static volatile double dummyDouble = 0.0f;
39 * NativeSignalHandler() -- handles (redirects) NT-generated signals.
42 NativeSignalHandler(int signo)
44 const char *signame = NULL;
47 /* Reinstall signal handler for signo; no reliable signals on NT */
48 (void)signal(signo, NativeSignalHandler);
50 /* NT defines few signals, and doesn't really generate all of these */
71 /* unexpect signo value */
76 if (signame != NULL) {
77 /* Redirect NT signal into process management library */
78 if (pmgt_SignalRaiseLocalByName(signame, &libSigno) == 0
79 && signo == SIGABRT) {
80 /* SIGABRT is a special case. It is generated by NT when abort()
81 * is called. Upon returning from the signal handler, abort()
82 * will terminate the process with an exit code of 3. In order
83 * to make an understandable termination status available to the
84 * process management library's waitpid() function, we exit
85 * the process here with a more appropriate exit code.
87 ExitProcess(PMGT_SIGSTATUS_ENCODE(libSigno));
94 * pmgt_RedirectNativeSignals() -- initialize native signal redirection.
97 pmgt_RedirectNativeSignals(void)
99 if (signal(SIGINT, NativeSignalHandler) == SIG_ERR
100 || signal(SIGILL, NativeSignalHandler) == SIG_ERR
101 || signal(SIGFPE, NativeSignalHandler) == SIG_ERR
102 || signal(SIGSEGV, NativeSignalHandler) == SIG_ERR
103 || signal(SIGTERM, NativeSignalHandler) == SIG_ERR
104 || signal(SIGABRT, NativeSignalHandler) == SIG_ERR) {
113 * pmgt_RedirectNativeSignals() -- initialize native signal redirection.
116 pmgt_RestoreNativeSignals(void)
118 if (signal(SIGINT, SIG_DFL) == SIG_ERR
119 || signal(SIGILL, SIG_DFL) == SIG_ERR
120 || signal(SIGFPE, SIG_DFL) == SIG_ERR
121 || signal(SIGSEGV, SIG_DFL) == SIG_ERR
122 || signal(SIGTERM, SIG_DFL) == SIG_ERR
123 || signal(SIGABRT, SIG_DFL) == SIG_ERR) {