diff options
author | Jacek Antonelli | 2008-12-01 17:39:58 -0600 |
---|---|---|
committer | Jacek Antonelli | 2008-12-01 17:40:06 -0600 |
commit | 7abecb48babe6a6f09bf6692ba55076546cfced9 (patch) | |
tree | 8d18a88513fb97adf32c10aae78f4be1984942db /linden/indra/newview/llappviewermacosx.cpp | |
parent | Second Life viewer sources 1.21.6 (diff) | |
download | meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.zip meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.tar.gz meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.tar.bz2 meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.tar.xz |
Second Life viewer sources 1.22.0-RC
Diffstat (limited to 'linden/indra/newview/llappviewermacosx.cpp')
-rw-r--r-- | linden/indra/newview/llappviewermacosx.cpp | 101 |
1 files changed, 93 insertions, 8 deletions
diff --git a/linden/indra/newview/llappviewermacosx.cpp b/linden/indra/newview/llappviewermacosx.cpp index 68c3a16..e3fd425 100644 --- a/linden/indra/newview/llappviewermacosx.cpp +++ b/linden/indra/newview/llappviewermacosx.cpp | |||
@@ -48,6 +48,7 @@ | |||
48 | #include "llurldispatcher.h" | 48 | #include "llurldispatcher.h" |
49 | #include <Carbon/Carbon.h> | 49 | #include <Carbon/Carbon.h> |
50 | #include "lldir.h" | 50 | #include "lldir.h" |
51 | #include <signal.h> | ||
51 | namespace | 52 | namespace |
52 | { | 53 | { |
53 | // The command line args stored. | 54 | // The command line args stored. |
@@ -193,22 +194,106 @@ bool LLAppViewerMacOSX::initParseCommandLine(LLCommandLineParser& clp) | |||
193 | return true; | 194 | return true; |
194 | } | 195 | } |
195 | 196 | ||
197 | // *FIX:Mani It would be nice to provide a clean interface to get the | ||
198 | // default_unix_signal_handler for the LLApp class. | ||
199 | extern void default_unix_signal_handler(int, siginfo_t *, void *); | ||
200 | bool LLAppViewerMacOSX::restoreErrorTrap() | ||
201 | { | ||
202 | // This method intends to reinstate signal handlers. | ||
203 | // *NOTE:Mani It was found that the first execution of a shader was overriding | ||
204 | // our initial signal handlers somehow. | ||
205 | // This method will be called (at least) once per mainloop execution. | ||
206 | // *NOTE:Mani The signals used below are copied over from the | ||
207 | // setup_signals() func in LLApp.cpp | ||
208 | // LLApp could use some way of overriding that func, but for this viewer | ||
209 | // fix I opt to avoid affecting the server code. | ||
210 | |||
211 | // Set up signal handlers that may result in program termination | ||
212 | // | ||
213 | struct sigaction act; | ||
214 | struct sigaction old_act; | ||
215 | act.sa_sigaction = default_unix_signal_handler; | ||
216 | sigemptyset( &act.sa_mask ); | ||
217 | act.sa_flags = SA_SIGINFO; | ||
218 | |||
219 | unsigned int reset_count = 0; | ||
220 | |||
221 | #define SET_SIG(S) sigaction(SIGABRT, &act, &old_act); \ | ||
222 | if((unsigned int)act.sa_sigaction != (unsigned int) old_act.sa_sigaction) \ | ||
223 | ++reset_count; | ||
224 | // Synchronous signals | ||
225 | SET_SIG(SIGABRT) | ||
226 | SET_SIG(SIGALRM) | ||
227 | SET_SIG(SIGBUS) | ||
228 | SET_SIG(SIGFPE) | ||
229 | SET_SIG(SIGHUP) | ||
230 | SET_SIG(SIGILL) | ||
231 | SET_SIG(SIGPIPE) | ||
232 | SET_SIG(SIGSEGV) | ||
233 | SET_SIG(SIGSYS) | ||
234 | |||
235 | SET_SIG(LL_HEARTBEAT_SIGNAL) | ||
236 | SET_SIG(LL_SMACKDOWN_SIGNAL) | ||
237 | |||
238 | // Asynchronous signals that are normally ignored | ||
239 | SET_SIG(SIGCHLD) | ||
240 | SET_SIG(SIGUSR2) | ||
241 | |||
242 | // Asynchronous signals that result in attempted graceful exit | ||
243 | SET_SIG(SIGHUP) | ||
244 | SET_SIG(SIGTERM) | ||
245 | SET_SIG(SIGINT) | ||
246 | |||
247 | // Asynchronous signals that result in core | ||
248 | SET_SIG(SIGQUIT) | ||
249 | #undef SET_SIG | ||
250 | |||
251 | return reset_count == 0; | ||
252 | } | ||
253 | |||
196 | void LLAppViewerMacOSX::handleSyncCrashTrace() | 254 | void LLAppViewerMacOSX::handleSyncCrashTrace() |
197 | { | 255 | { |
198 | // do nothing | 256 | // do nothing |
199 | } | 257 | } |
200 | 258 | ||
201 | void LLAppViewerMacOSX::handleCrashReporting() | 259 | void LLAppViewerMacOSX::handleCrashReporting(bool reportFreeze) |
202 | { | 260 | { |
203 | // Macintosh | ||
204 | std::string command_str; | 261 | std::string command_str; |
205 | command_str += "open mac-crash-logger.app"; | 262 | //command_str = "open Second Life.app/Contents/Resources/mac-crash-logger.app"; |
263 | command_str = "mac-crash-logger.app/Contents/MacOS/mac-crash-logger"; | ||
206 | 264 | ||
207 | clear_signals(); | 265 | FSRef appRef; |
208 | llinfos << "Launching crash reporter using: '" << command_str << "'" << llendl; | 266 | Boolean isDir = 0; |
209 | system(command_str.c_str()); /* Flawfinder: ignore */ | 267 | OSStatus os_result = FSPathMakeRef((UInt8*)command_str.c_str(), |
210 | llinfos << "returned from crash reporter... dying" << llendl; | 268 | &appRef, |
211 | _exit(1); | 269 | &isDir); |
270 | if(os_result >= 0) | ||
271 | { | ||
272 | LSApplicationParameters appParams; | ||
273 | memset(&appParams, 0, sizeof(appParams)); | ||
274 | appParams.version = 0; | ||
275 | appParams.flags = kLSLaunchNoParams | kLSLaunchStartClassic; | ||
276 | appParams.application = &appRef; | ||
277 | |||
278 | if(reportFreeze) | ||
279 | { | ||
280 | // Make sure freeze reporting launches the crash logger synchronously, lest | ||
281 | // Log files get changed by SL while the logger is running. | ||
282 | } | ||
283 | else | ||
284 | { | ||
285 | appParams.flags |= kLSLaunchAsync; | ||
286 | clear_signals(); | ||
287 | } | ||
288 | |||
289 | ProcessSerialNumber o_psn; | ||
290 | os_result = LSOpenApplication(&appParams, &o_psn); | ||
291 | } | ||
292 | |||
293 | if(!reportFreeze) | ||
294 | { | ||
295 | _exit(1); | ||
296 | } | ||
212 | } | 297 | } |
213 | 298 | ||
214 | std::string LLAppViewerMacOSX::generateSerialNumber() | 299 | std::string LLAppViewerMacOSX::generateSerialNumber() |