1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 27 #include <signal.h> 28 29 #include <bsd/bsd.h> 30 31 /* External references. 32 */ 33 34 /* Forward references. 35 */ 36 37 /* Static data. 38 */ 39 40 extern SIG_PF 41 bsd_signal (int Signal, SIG_PF Handler) 42 { 43 auto SIG_PF previous_handler; 44 #ifdef SUN5_0 45 #ifdef sun 46 previous_handler = sigset (Signal, Handler); 47 #else 48 auto struct sigaction new_action; 49 auto struct sigaction old_action; 50 51 new_action.sa_flags = SA_SIGINFO; 52 new_action.sa_handler = (void (*) ()) Handler; 53 (void) sigemptyset (&new_action.sa_mask); 54 (void) sigaddset (&new_action.sa_mask, Signal); 55 56 (void) sigaction (Signal, &new_action, &old_action); 57 58 previous_handler = (SIG_PF) old_action.sa_handler; 59 #endif 60 #elif defined(linux) 61 previous_handler = sigset (Signal, Handler); 62 #else 63 previous_handler = signal (Signal, Handler); 64 #endif 65 return previous_handler; 66 } 67 68 extern void 69 bsd_signals (void) 70 { 71 static int initialized = 0; 72 73 if (initialized == 0) 74 { 75 initialized = 1; 76 #if !defined(SUN5_0) && !defined(linux) 77 #if defined(SIGHUP) 78 (void) bsd_signal (SIGHUP, SIG_DFL); 79 #endif 80 #if defined(SIGINT) 81 (void) bsd_signal (SIGINT, SIG_DFL); 82 #endif 83 #if defined(SIGQUIT) 84 (void) bsd_signal (SIGQUIT, SIG_DFL); 85 #endif 86 #if defined(SIGILL) 87 (void) bsd_signal (SIGILL, SIG_DFL); 88 #endif 89 #if defined(SIGTRAP) 90 (void) bsd_signal (SIGTRAP, SIG_DFL); 91 #endif 92 #if defined(SIGIOT) 93 (void) bsd_signal (SIGIOT, SIG_DFL); 94 #endif 95 #if defined(SIGABRT) 96 (void) bsd_signal (SIGABRT, SIG_DFL); 97 #endif 98 #if defined(SIGEMT) 99 (void) bsd_signal (SIGEMT, SIG_DFL); 100 #endif 101 #if defined(SIGFPE) 102 (void) bsd_signal (SIGFPE, SIG_DFL); 103 #endif 104 #if defined(SIGBUS) 105 (void) bsd_signal (SIGBUS, SIG_DFL); 106 #endif 107 #if defined(SIGSEGV) 108 (void) bsd_signal (SIGSEGV, SIG_DFL); 109 #endif 110 #if defined(SIGSYS) 111 (void) bsd_signal (SIGSYS, SIG_DFL); 112 #endif 113 #if defined(SIGPIPE) 114 (void) bsd_signal (SIGPIPE, SIG_DFL); 115 #endif 116 #if defined(SIGALRM) 117 (void) bsd_signal (SIGALRM, SIG_DFL); 118 #endif 119 #if defined(SIGTERM) 120 (void) bsd_signal (SIGTERM, SIG_DFL); 121 #endif 122 #if defined(SIGUSR1) 123 (void) bsd_signal (SIGUSR1, SIG_DFL); 124 #endif 125 #if defined(SIGUSR2) 126 (void) bsd_signal (SIGUSR2, SIG_DFL); 127 #endif 128 #if defined(SIGCLD) 129 (void) bsd_signal (SIGCLD, SIG_DFL); 130 #endif 131 #if defined(SIGCHLD) 132 (void) bsd_signal (SIGCHLD, SIG_DFL); 133 #endif 134 #if defined(SIGPWR) 135 (void) bsd_signal (SIGPWR, SIG_DFL); 136 #endif 137 #if defined(SIGWINCH) 138 (void) bsd_signal (SIGWINCH, SIG_DFL); 139 #endif 140 #if defined(SIGURG) 141 (void) bsd_signal (SIGURG, SIG_DFL); 142 #endif 143 #if defined(SIGIO) 144 (void) bsd_signal (SIGIO, SIG_DFL); 145 #else 146 #if defined(SIGPOLL) 147 (void) bsd_signal (SIGPOLL, SIG_DFL); 148 #endif 149 #endif 150 #if defined(SIGTSTP) 151 (void) bsd_signal (SIGTSTP, SIG_DFL); 152 #endif 153 #if defined(SIGCONT) 154 (void) bsd_signal (SIGCONT, SIG_DFL); 155 #endif 156 #if defined(SIGTTIN) 157 (void) bsd_signal (SIGTTIN, SIG_DFL); 158 #endif 159 #if defined(SIGTTOU) 160 (void) bsd_signal (SIGTTOU, SIG_DFL); 161 #endif 162 #if defined(SIGVTALRM) 163 (void) bsd_signal (SIGVTALRM, SIG_DFL); 164 #endif 165 #if defined(SIGPROF) 166 (void) bsd_signal (SIGPROF, SIG_DFL); 167 #endif 168 #if defined(SIGXCPU) 169 (void) bsd_signal (SIGXCPU, SIG_DFL); 170 #endif 171 #if defined(SIGXFSZ) 172 (void) bsd_signal (SIGXFSZ, SIG_DFL); 173 #endif 174 #endif 175 } 176 177 return; 178 }