Followup to bug 535802, make it work on Linux too by passing around the program name from argv[0]
authorBenjamin Smedberg <benjamin@smedbergs.us>
Fri, 18 Dec 2009 17:14:53 -0500
changeset 46481 dcd026cef0067bde167d37649a8bae5ac5384e0c
parent 46480 b37028cc62e7a59691e1989af069481527bf8a82
child 46482 03cb6e94b2b1d6e03fd7728f19731f0e57a034ed
push idunknown
push userunknown
push dateunknown
bugs535802
milestone1.9.3a1pre
Followup to bug 535802, make it work on Linux too by passing around the program name from argv[0]
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsAppRunner.h
toolkit/xre/nsEmbedFunctions.cpp
toolkit/xre/nsSigHandlers.cpp
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -2635,17 +2635,17 @@ XRE_main(int argc, char* argv[], const n
   ArgResult ar;
   NS_TIMELINE_MARK("enter main");
 
 #ifdef DEBUG
   if (PR_GetEnv("XRE_MAIN_BREAK"))
     NS_BREAK();
 #endif
 
-  SetupErrorHandling();
+  SetupErrorHandling(argv[0]);
 
 #ifdef MOZ_ACCESSIBILITY_ATK
   // Reset GTK_MODULES, strip atk-bridge if exists
   // Mozilla will load libatk-bridge.so later if necessary
   const char* gtkModules = PR_GetEnv("GTK_MODULES");
   if (gtkModules && *gtkModules) {
     nsCString gtkModulesStr(gtkModules);
     gtkModulesStr.ReplaceSubstring("atk-bridge", "");
@@ -3657,17 +3657,17 @@ XRE_GetProcessType()
 #ifdef MOZ_IPC
   return mozilla::startup::sChildProcessType;
 #else
   return GeckoProcessType_Default;
 #endif
 }
 
 void
-SetupErrorHandling()
+SetupErrorHandling(const char* progname)
 {
 #ifdef XP_WIN
   /* On Windows XPSP3 and Windows Vista if DEP is configured off-by-default
      we still want DEP protection: enable it explicitly and programmatically.
      
      This function is not available on WinXPSP2 so we dynamically load it.
   */
 
@@ -3698,17 +3698,17 @@ SetupErrorHandling()
   // accurate heap numbers. Win2k non-debug does not use small heap allocator.
   // Win2k debug seems to be still using it.
   // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__set_sbh_threshold.asp
   _set_sbh_threshold(0);
 #endif
 #endif
 
 #if defined(XP_UNIX) || defined(XP_BEOS)
-  InstallUnixSignalHandlers(argv[0]);
+  InstallUnixSignalHandlers(progname);
 #endif
 
 #ifndef WINCE
   // Unbuffer stdout, needed for tinderbox tests.
   setbuf(stdout, 0);
 #endif
 
 #if defined(FREEBSD)
--- a/toolkit/xre/nsAppRunner.h
+++ b/toolkit/xre/nsAppRunner.h
@@ -189,11 +189,11 @@ extern GeckoProcessType sChildProcessTyp
 }
 }
 #endif
 
 /**
  * Set up platform specific error handling such as suppressing DLL load dialog
  * and the JIT debugger on Windows, and install unix signal handlers.
  */
-void SetupErrorHandling();
+void SetupErrorHandling(const char* progname);
 
 #endif // nsAppRunner_h__
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -257,17 +257,17 @@ nsresult
 XRE_InitChildProcess(int aArgc,
                      char* aArgv[],
                      GeckoProcessType aProcess)
 {
   NS_ENSURE_ARG_MIN(aArgc, 2);
   NS_ENSURE_ARG_POINTER(aArgv);
   NS_ENSURE_ARG_POINTER(aArgv[0]);
 
-  SetupErrorHandling();
+  SetupErrorHandling(aArgv[0]);
 
   sChildProcessType = aProcess;
   
 #if defined(MOZ_WIDGET_GTK2)
   g_thread_init(NULL);
 #endif
 
   if (PR_GetEnv("MOZ_DEBUG_CHILD_PROCESS")) {
--- a/toolkit/xre/nsSigHandlers.cpp
+++ b/toolkit/xre/nsSigHandlers.cpp
@@ -224,20 +224,22 @@ void InstallUnixSignalHandlers(const cha
   signal(SIGINT,  abnormal_exit_handler);
   signal(SIGHUP,  abnormal_exit_handler);
   signal(SIGSEGV, abnormal_exit_handler);
   signal(SIGILL,  abnormal_exit_handler);
   signal(SIGABRT, abnormal_exit_handler);
   signal(SIGFPE,  abnormal_exit_handler);
 
 #elif defined(CRAWL_STACK_ON_SIGSEGV)
-  signal(SIGSEGV, ah_crap_handler);
-  signal(SIGILL, ah_crap_handler);
-  signal(SIGABRT, ah_crap_handler);
-  signal(SIGFPE, ah_crap_handler);
+  if (!getenv("XRE_NO_WINDOWS_CRASH_DIALOG")) {
+    signal(SIGSEGV, ah_crap_handler);
+    signal(SIGILL, ah_crap_handler);
+    signal(SIGABRT, ah_crap_handler);
+    signal(SIGFPE, ah_crap_handler);
+  }
 #endif // CRAWL_STACK_ON_SIGSEGV
 
 #if defined(DEBUG) && defined(LINUX)
   const char *memLimit = PR_GetEnv("MOZ_MEM_LIMIT");
   if (memLimit && *memLimit)
   {
     long m = atoi(memLimit);
     m *= (1024*1024);