fm: remove sparc-only modules
[unleashed.git] / usr / src / lib / efcode / engine / signal.c
bloba023bfd8572a91606cb8f2d549a762dbc4ee6294
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright (c) 1999 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <signal.h>
33 #include <unistd.h>
35 #include <sys/time.h>
36 #include <sys/termio.h>
38 #include <fcode/private.h>
39 #include <fcode/log.h>
41 static fcode_env_t *saved_envp;
42 static struct termio saved_termio;
44 static void
45 process_signal(int sig, siginfo_t *sip, void *addr)
48 * Format appropriate error message, want fault addr if Bus Error
49 * or Segmentation Violation.
51 switch (sig) {
52 case SIGSEGV:
53 case SIGBUS:
54 case SIGILL:
55 case SIGFPE:
56 forth_abort(saved_envp, "%s: Fault Addr: 0x%08x",
57 strsignal(sig), sip->si_addr);
59 case SIGQUIT:
60 ioctl(fileno(stdin), TCSETA, &saved_termio);
61 log_message(MSG_FATAL, "SIGQUIT\n");
62 abort();
64 case SIGINT:
65 ioctl(fileno(stdin), TCSETA, &saved_termio);
66 break;
68 forth_abort(saved_envp, strsignal(sig));
71 void
72 install_handlers(fcode_env_t *env)
74 struct sigaction sa;
76 saved_envp = env;
78 ioctl(fileno(stdin), TCGETA, &saved_termio);
80 sigemptyset(&sa.sa_mask);
81 sa.sa_flags = SA_SIGINFO|SA_NODEFER;
82 sa.sa_handler = 0;
83 sa.sa_sigaction = process_signal;
85 sigaction(SIGINT, &sa, NULL);
86 sigaction(SIGQUIT, &sa, NULL);
87 sigaction(SIGSEGV, &sa, NULL);
88 sigaction(SIGBUS, &sa, NULL);
89 sigaction(SIGUSR1, &sa, NULL);
90 sigaction(SIGFPE, &sa, NULL);