- Timestamp:
- Apr 24, 2005, 1:06:47 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/src/emx/src/lib/sys/signals.c (modified) (11 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/src/lib/sys/signals.c
-
Property cvs2svn:cvs-rev
changed from
1.24to1.25
r1880 r1881 206 206 __LIBC_PTHREAD pThrd; 207 207 } SIGSCHEDENUMPARAM, *PSIGSCHEDENUMPARAM; 208 209 210 211 212 213 214 215 216 217 218 219 208 220 209 221 … … 555 567 static int signalDeliver(__LIBC_PTHREAD pThrd, int iSignalNo, void *pvXcptParams); 556 568 static void signalTerminate(int iSignalNo) __dead2; 557 static void signalTerminateAbnormal(int iSignalNo) __dead2; 558 static int signalTerminateHex(char *pszBuf, unsigned u); 569 static void signalTerminateAbnormal(int iSignalNo, void *pvXcptParams) __dead2; 559 570 static int signalJobStop(int iSignalNo); 560 571 static int signalJobResume(void); … … 1012 1023 LIBCLOG_MSG("we're toast!\n"); 1013 1024 DosWrite(HFILE_STDERR, szMsg, sizeof(szMsg) - 1, &cb); 1014 signalTerminateAbnormal(iSignalNo );1025 signalTerminateAbnormal(iSignalNo); 1015 1026 } 1016 1027 … … 1778 1789 * @param iSignalNo Deliver the first signal of this type no matter if it's 1779 1790 * blocked or not. This is for use with hardware signals only! 1780 * @param pvXcptParams sPointer to exception parameter list is any.1791 * @param pvXcptParams Pointer to exception parameter list is any. 1781 1792 */ 1782 1793 static int signalDeliver(__LIBC_PTHREAD pThrd, int iSignalNo, void *pvXcptParams) … … 1883 1894 case SPA_CORE: 1884 1895 case SPA_NEXT_CORE: 1885 signalTerminateAbnormal(iSignalNo );1896 signalTerminateAbnormal(iSignalNo); 1886 1897 break; 1887 1898 … … 2037 2048 } 2038 2049 2050 2039 2051 /** 2040 2052 * Cause immediate process termination because of the given signal. … … 2050 2062 */ 2051 2063 __libc_spmTerm(__LIBC_EXIT_REASON_SIGNAL_BASE + iSignalNo, 127); 2052 LIBCLOG_MSG("Calling Dos Exit(,127)\n");2064 LIBCLOG_MSG("Calling Dos)\n"); 2053 2065 for (;;) 2054 2066 { 2055 2067 DosKillProcess(DKP_PROCESS, 0); 2056 DosExit(EXIT_THREAD, 127); 2057 } 2058 } 2059 2060 /** 2061 * Cause immediate process termination because of the given signal. 2062 * 2063 * @param iSignalNo Signal causing the termination. 2064 */ 2065 static void signalTerminateAbnormal(int iSignalNo) 2066 { 2067 LIBCLOG_ENTER("iSignalNo=%d\n", iSignalNo); 2068 /* 2069 * Set the exit reason in SPM. 2070 */ 2071 __libc_spmTerm(__LIBC_EXIT_REASON_SIGNAL_BASE + iSignalNo, 127); 2072 2073 /* 2074 * Before we go crazy here, let's release the semaphore. 2075 * 2076 * If possible we'll stay in the must complete section to 2077 * be sure we get to the exit. If not we'll have to mess with 2078 * exception handlers and such now. 2079 */ 2080 //if (__libc_back_signalSemIsOwner()) 2081 // DosReleaseMutexSem(ghmtxSignals); 2082 2083 /* 2084 * Terminate the exception handler chain to avoid recursive trouble. 2085 */ 2086 FS_VAR(); 2087 FS_SAVE_LOAD(); 2088 PTIB pTib; 2089 PPIB pPib; 2090 DosGetInfoBlocks(&pTib, &pPib); 2091 pTib->tib_pexchain = END_OF_CHAIN; 2092 2093 /* 2094 * Write message to stderr. 2095 */ 2096 ULONG cb; 2097 if (iSignalNo == SIGABRT) 2098 { 2099 static const char szMsg[] = "\n\rAbnormal program termination"; 2100 DosWrite(HFILE_STDERR, szMsg, sizeof(szMsg) - 1, &cb); 2101 } 2102 else 2103 { 2104 static const char szMsg[] = "\n\rProcess terminated by "; 2105 DosWrite(HFILE_STDERR, szMsg, sizeof(szMsg) - 1, &cb); 2106 2107 const char *psz = "unknown signal"; 2108 if (iSignalNo < sizeof(gaszSignalNames) / sizeof(gaszSignalNames[0])) 2109 psz = gaszSignalNames[iSignalNo]; 2110 for (cb = 0; psz[cb];) 2111 cb++; 2112 DosWrite(HFILE_STDERR, psz, cb, &cb); 2113 } 2114 2115 /* pid */ 2116 static const char szMsgPid[] = " - pid=0x"; 2117 DosWrite(HFILE_STDERR, szMsgPid, sizeof(szMsgPid) - 1, &cb); 2118 char szHexNum[12]; 2119 cb = signalTerminateHex(szHexNum, pPib->pib_ulpid); 2120 DosWrite(HFILE_STDERR, szHexNum, cb, &cb); 2121 2122 /* tid */ 2123 static const char szMsgTid[] = " - tid=0x"; 2124 DosWrite(HFILE_STDERR, szMsgTid, sizeof(szMsgTid) - 1, &cb); 2125 cb = signalTerminateHex(szHexNum, pTib->tib_ptib2->tib2_ultid); 2126 DosWrite(HFILE_STDERR, szHexNum, cb, &cb); 2127 2128 /* executable name. */ 2129 static char szExeName[CCHMAXPATH]; 2130 if (!DosQueryModuleName(pPib->pib_hmte, sizeof(szExeName), &szExeName[0])) 2131 { 2132 static const char szHypen[] = " - "; 2133 DosWrite(HFILE_STDERR, szHypen, sizeof(szHypen) - 1, &cb); 2134 2135 for (cb = 0; szExeName[cb];) 2136 cb++; 2137 DosWrite(HFILE_STDERR, szExeName, cb, &cb); 2138 } 2139 2140 /* final newline */ 2141 static const char szNewLine[] = "\r\n"; 2142 DosWrite(HFILE_STDERR, szNewLine, sizeof(szNewLine) - 1, &cb); 2143 2144 /* 2145 * Terminate the process. 2146 */ 2147 LIBCLOG_MSG("Calling DosExit(,127)\n"); 2148 for (;;) 2149 { 2150 DosKillProcess(DKP_PROCESS, 0); 2151 DosExit(EXIT_THREAD, 127); 2152 } 2153 } 2068 DosExit(EXIT_PROCESS, 127); 2069 } 2070 } 2071 2072 2073 /** 2074 * Calculates the length of a string. 2075 * @returns String length in bytes. 2076 * @param psz Pointer to the string. 2077 */ 2078 static size_t signalTerminateStrLen(const char *psz) 2079 { 2080 const char *pszEnd = psz; 2081 while (*pszEnd) 2082 pszEnd++; 2083 return pszEnd - psz; 2084 } 2085 2154 2086 2155 2087 /** … … 2159 2091 * @param pszBuf Where to store the formatted number. 2160 2092 * @param u Number to format. 2161 */ 2162 static int signalTerminateHex(char *pszBuf, unsigned u) 2093 * @param cDigits Minimum number of digits in the output. Use 0 for whatever fits. 2094 */ 2095 static int signalTerminateHex(char *pszBuf, unsigned u, unsigned cDigits) 2163 2096 { 2164 2097 static const char szHex[17] = "0123456789abcdef"; 2165 if (u <= 0xff) 2098 if (u <= 0xf && cDigits <= 1) 2099 { 2100 pszBuf[0] = szHex[u & 0xf]; 2101 pszBuf[1] = '\0'; 2102 return 1; 2103 } 2104 if (u <= 0xff && cDigits <= 2) 2166 2105 { 2167 2106 pszBuf[0] = szHex[u >> 4]; … … 2170 2109 return 2; 2171 2110 } 2172 else if (u <= 0xffff )2111 else if (u <= 0xffff) 2173 2112 { 2174 2113 pszBuf[0] = szHex[u >> 12]; … … 2194 2133 } 2195 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2196 2255 /** 2197 2256 * Stop the process (job control emulation). … … 2222 2281 return __libc_back_signalSemRequest(); 2223 2282 } 2283 2224 2284 2225 2285 /** -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.
