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 /* 23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #include <sys/signal.h> 28 #include <lx_signum.h> 29 30 /* 31 * Delivering signals to a Linux process is complicated by differences in 32 * signal numbering, stack structure and contents, and the action taken when a 33 * signal handler exits. In addition, many signal-related structures, such as 34 * sigset_ts, vary between Solaris and Linux. 35 * 36 * The simplest transformation that must be done when sending signals is to 37 * translate between Linux and Solaris signal numbers. 38 * 39 * These are the major signal number differences between Linux and Solaris: 40 * 41 * ==================================== 42 * | Number | Linux | Solaris | 43 * | ====== | ========= | ========== | 44 * | 7 | SIGBUS | SIGEMT | 45 * | 10 | SIGUSR1 | SIGBUS | 46 * | 12 | SIGUSR2 | SIGSYS | 47 * | 16 | SIGSTKFLT | SIGUSR1 | 48 * | 17 | SIGCHLD | SIGUSR2 | 49 * | 18 | SIGCONT | SIGCHLD | 50 * | 19 | SIGSTOP | SIGPWR | 51 * | 20 | SIGTSTP | SIGWINCH | 52 * | 21 | SIGTTIN | SIGURG | 53 * | 22 | SIGTTOU | SIGPOLL | 54 * | 23 | SIGURG | SIGSTOP | 55 * | 24 | SIGXCPU | SIGTSTP | 56 * | 25 | SIGXFSZ | SIGCONT | 57 * | 26 | SIGVTALARM | SIGTTIN | 58 * | 27 | SIGPROF | SIGTTOU | 59 * | 28 | SIGWINCH | SIGVTALARM | 60 * | 29 | SIGPOLL | SIGPROF | 61 * | 30 | SIGPWR | SIGXCPU | 62 * | 31 | SIGSYS | SIGXFSZ | 63 * ==================================== 64 * 65 * Not every Linux signal maps to a Solaris signal, nor does every Solaris 66 * signal map to a Linux counterpart. However, when signals do map, the 67 * mapping is unique. 68 * 69 * One mapping issue is that Linux supports 33 real time signals, with SIGRTMIN 70 * typically starting at or near 32 (SIGRTMIN) and proceeding to 64 (SIGRTMAX) 71 * (SIGRTMIN is "at or near" 32 because glibc usually "steals" one ore more of 72 * these signals for its own internal use, adjusting SIGRTMIN and SIGRTMAX as 73 * needed.) Conversely, Solaris actively uses signals 32-40 for other purposes 74 * and supports exactly 32 real time signals, in the range 41 (SIGRTMIN) 75 * to 72 (SIGRTMAX). 76 * 77 * At present, attempting to translate a Linux signal equal to 63 78 * will generate an error (we allow SIGRTMAX because a program 79 * should be able to send SIGRTMAX without getting an EINVAL, though obviously 80 * anything that loops through the signals from SIGRTMIN to SIGRTMAX will 81 * fail.) 82 * 83 * Similarly, attempting to translate a native Solaris signal in the range 84 * 32-40 will also generate an error as we don't want to support the receipt of 85 * those signals from the Solaris global zone. 86 */ 87 88 /* 89 * Linux to Solaris signal map 90 * 91 * Usage: solaris_signal = ltos_signum[lx_signal]; 92 */ 93 const int 94 ltos_signo[LX_NSIG] = { 95 0, 96 SIGHUP, 97 SIGINT, 98 SIGQUIT, 99 SIGILL, 100 SIGTRAP, 101 SIGABRT, 102 SIGBUS, 103 SIGFPE, 104 SIGKILL, 105 SIGUSR1, 106 SIGSEGV, 107 SIGUSR2, 108 SIGPIPE, 109 SIGALRM, 110 SIGTERM, 111 SIGEMT, /* 16: Linux SIGSTKFLT; use Solaris SIGEMT */ 112 SIGCHLD, 113 SIGCONT, 114 SIGSTOP, 115 SIGTSTP, 116 SIGTTIN, 117 SIGTTOU, 118 SIGURG, 119 SIGXCPU, 120 SIGXFSZ, 121 SIGVTALRM, 122 SIGPROF, 123 SIGWINCH, 124 SIGPOLL, 125 SIGPWR, 126 SIGSYS, 127 _SIGRTMIN, /* 32: Linux SIGRTMIN */ 128 _SIGRTMIN + 1, 129 _SIGRTMIN + 2, 130 _SIGRTMIN + 3, 131 _SIGRTMIN + 4, 132 _SIGRTMIN + 5, 133 _SIGRTMIN + 6, 134 _SIGRTMIN + 7, 135 _SIGRTMIN + 8, 136 _SIGRTMIN + 9, 137 _SIGRTMIN + 10, 138 _SIGRTMIN + 11, 139 _SIGRTMIN + 12, 140 _SIGRTMIN + 13, 141 _SIGRTMIN + 14, 142 _SIGRTMIN + 15, 143 _SIGRTMIN + 16, 144 _SIGRTMIN + 17, 145 _SIGRTMIN + 18, 146 _SIGRTMIN + 19, 147 _SIGRTMIN + 20, 148 _SIGRTMIN + 21, 149 _SIGRTMIN + 22, 150 _SIGRTMIN + 23, 151 _SIGRTMIN + 24, 152 _SIGRTMIN + 25, 153 _SIGRTMIN + 26, 154 _SIGRTMIN + 27, 155 _SIGRTMIN + 28, 156 _SIGRTMIN + 29, 157 _SIGRTMIN + 30, 158 -1, /* 63: Linux SIGRTMIN + 31, or SIGRTMAX - 1 */ 159 _SIGRTMAX, /* 64: Linux SIGRTMAX */ 160 }; 161 162 /* 163 * Solaris to Linux signal map 164 * 165 * Usage: lx_signal = stol_signo[solaris_signal]; 166 */ 167 const int 168 stol_signo[NSIG] = { 169 0, 170 LX_SIGHUP, 171 LX_SIGINT, 172 LX_SIGQUIT, 173 LX_SIGILL, 174 LX_SIGTRAP, 175 LX_SIGABRT, 176 LX_SIGSTKFLT, /* 7: Solaris SIGEMT; use for LX_SIGSTKFLT */ 177 LX_SIGFPE, 178 LX_SIGKILL, 179 LX_SIGBUS, 180 LX_SIGSEGV, 181 LX_SIGSYS, 182 LX_SIGPIPE, 183 LX_SIGALRM, 184 LX_SIGTERM, 185 LX_SIGUSR1, 186 LX_SIGUSR2, 187 LX_SIGCHLD, 188 LX_SIGPWR, 189 LX_SIGWINCH, 190 LX_SIGURG, 191 LX_SIGPOLL, 192 LX_SIGSTOP, 193 LX_SIGTSTP, 194 LX_SIGCONT, 195 LX_SIGTTIN, 196 LX_SIGTTOU, 197 LX_SIGVTALRM, 198 LX_SIGPROF, 199 LX_SIGXCPU, 200 LX_SIGXFSZ, 201 -1, /* 32: Solaris SIGWAITING */ 202 -1, /* 33: Solaris SIGLWP */ 203 -1, /* 34: Solaris SIGFREEZE */ 204 -1, /* 35: Solaris SIGTHAW */ 205 -1, /* 36: Solaris SIGCANCEL */ 206 -1, /* 37: Solaris SIGLOST */ 207 -1, /* 38: Solaris SIGXRES */ 208 -1, /* 39: Solaris SIGJVM1 */ 209 -1, /* 40: Solaris SIGJVM2 */ 210 LX_SIGRTMIN, /* 41: Solaris _SIGRTMIN */ 211 LX_SIGRTMIN + 1, 212 LX_SIGRTMIN + 2, 213 LX_SIGRTMIN + 3, 214 LX_SIGRTMIN + 4, 215 LX_SIGRTMIN + 5, 216 LX_SIGRTMIN + 6, 217 LX_SIGRTMIN + 7, 218 LX_SIGRTMIN + 8, 219 LX_SIGRTMIN + 9, 220 LX_SIGRTMIN + 10, 221 LX_SIGRTMIN + 11, 222 LX_SIGRTMIN + 12, 223 LX_SIGRTMIN + 13, 224 LX_SIGRTMIN + 14, 225 LX_SIGRTMIN + 15, 226 LX_SIGRTMIN + 16, 227 LX_SIGRTMIN + 17, 228 LX_SIGRTMIN + 18, 229 LX_SIGRTMIN + 19, 230 LX_SIGRTMIN + 20, 231 LX_SIGRTMIN + 21, 232 LX_SIGRTMIN + 22, 233 LX_SIGRTMIN + 23, 234 LX_SIGRTMIN + 24, 235 LX_SIGRTMIN + 25, 236 LX_SIGRTMIN + 26, 237 LX_SIGRTMIN + 27, 238 LX_SIGRTMIN + 28, 239 LX_SIGRTMIN + 29, 240 LX_SIGRTMIN + 30, 241 LX_SIGRTMAX, /* 72: Solaris _SIGRTMAX */ 242 };