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>
17 #include "pmgtprivate.h"
19 /* Implements native-signal redirection. Basically, NT generated signals
20 * are caught and passed through to the signal functions implemented by
21 * this process management library.
23 * Note that signals are passed through by name, since procmgmt.h can't
24 * be included here (given that signal(), raise(), etc. are redefined).
28 /* Program must have FP code to trap SIGFPE; MS suggests the following def. */
29 static volatile double dummyDouble
= 0.0f
;
33 * NativeSignalHandler() -- handles (redirects) NT-generated signals.
36 NativeSignalHandler(int signo
)
38 const char *signame
= NULL
;
41 /* Reinstall signal handler for signo; no reliable signals on NT */
42 (void)signal(signo
, NativeSignalHandler
);
44 /* NT defines few signals, and doesn't really generate all of these */
65 /* unexpect signo value */
70 if (signame
!= NULL
) {
71 /* Redirect NT signal into process management library */
72 if (pmgt_SignalRaiseLocalByName(signame
, &libSigno
) == 0
73 && signo
== SIGABRT
) {
74 /* SIGABRT is a special case. It is generated by NT when abort()
75 * is called. Upon returning from the signal handler, abort()
76 * will terminate the process with an exit code of 3. In order
77 * to make an understandable termination status available to the
78 * process management library's waitpid() function, we exit
79 * the process here with a more appropriate exit code.
81 ExitProcess(PMGT_SIGSTATUS_ENCODE(libSigno
));
88 * pmgt_RedirectNativeSignals() -- initialize native signal redirection.
91 pmgt_RedirectNativeSignals(void)
93 if (signal(SIGINT
, NativeSignalHandler
) == SIG_ERR
94 || signal(SIGILL
, NativeSignalHandler
) == SIG_ERR
95 || signal(SIGFPE
, NativeSignalHandler
) == SIG_ERR
96 || signal(SIGSEGV
, NativeSignalHandler
) == SIG_ERR
97 || signal(SIGTERM
, NativeSignalHandler
) == SIG_ERR
98 || signal(SIGABRT
, NativeSignalHandler
) == SIG_ERR
) {
107 * pmgt_RedirectNativeSignals() -- initialize native signal redirection.
110 pmgt_RestoreNativeSignals(void)
112 if (signal(SIGINT
, SIG_DFL
) == SIG_ERR
113 || signal(SIGILL
, SIG_DFL
) == SIG_ERR
114 || signal(SIGFPE
, SIG_DFL
) == SIG_ERR
115 || signal(SIGSEGV
, SIG_DFL
) == SIG_ERR
116 || signal(SIGTERM
, SIG_DFL
) == SIG_ERR
117 || signal(SIGABRT
, SIG_DFL
) == SIG_ERR
) {