Adding nsSigHandlers file to pull out unix signal handlers into a
seperate file. r=Ramiro git-svn-id: svn://10.0.0.236/trunk@53950 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
78cb9bc6ed
commit
03e774325c
@ -32,6 +32,7 @@ PROGRAM = mozilla-bin
|
||||
CPPSRCS = \
|
||||
nsAppRunner.cpp \
|
||||
nsSetupRegistry.cpp \
|
||||
nsSigHandlers.cpp \
|
||||
$(NULL)
|
||||
|
||||
XP_DIST_LIBS = \
|
||||
|
||||
@ -75,6 +75,10 @@ static NS_DEFINE_CID(kCookieServiceCID, NS_COOKIESERVICE_CID);
|
||||
// header file for profile manager
|
||||
#include "nsIProfile.h"
|
||||
|
||||
#if defined(XP_UNIX)
|
||||
extern void InstallUnixSignalHandlers(const char *ProgramName);
|
||||
#endif
|
||||
|
||||
#if defined(XP_MAC)
|
||||
|
||||
#include "macstdlibextras.h"
|
||||
@ -600,52 +604,12 @@ void DumpVersion(char *appname)
|
||||
printf("%s: version info\n", appname);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ramiro
|
||||
#define CRAWL_STACK_ON_SIGSEGV
|
||||
#endif // DEBUG_ramiro
|
||||
|
||||
#ifdef CRAWL_STACK_ON_SIGSEGV
|
||||
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include "nsTraceRefcnt.h"
|
||||
|
||||
extern "C" char * strsignal(int);
|
||||
|
||||
static char _progname[1024] = "huh?";
|
||||
|
||||
void
|
||||
ah_crap_handler(int signum)
|
||||
{
|
||||
PR_CurrentThread();
|
||||
|
||||
printf("prog = %s\npid = %d\nsignal = %s\n",
|
||||
_progname,
|
||||
getpid(),
|
||||
strsignal(signum));
|
||||
|
||||
printf("stack logged to someplace\n");
|
||||
nsTraceRefcnt::WalkTheStack(stdout);
|
||||
|
||||
printf("Sleeping for 5 minutes.\n");
|
||||
printf("Type 'gdb %s %d' to attatch your debugger to this thread.\n",
|
||||
_progname,
|
||||
getpid());
|
||||
|
||||
sleep(300);
|
||||
|
||||
printf("Done sleeping...\n");
|
||||
}
|
||||
#endif // CRAWL_STACK_ON_SIGSEGV
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#ifdef CRAWL_STACK_ON_SIGSEGV
|
||||
strcpy(_progname,argv[0]);
|
||||
signal(SIGSEGV, ah_crap_handler);
|
||||
signal(SIGILL, ah_crap_handler);
|
||||
signal(SIGABRT, ah_crap_handler);
|
||||
#endif // CRAWL_STACK_ON_SIGSEGV
|
||||
#if defined(XP_UNIX)
|
||||
InstallUnixSignalHandlers(argv[0]);
|
||||
#endif
|
||||
|
||||
nsresult rv;
|
||||
|
||||
|
||||
119
mozilla/xpfe/bootstrap/nsSigHandlers.cpp
Normal file
119
mozilla/xpfe/bootstrap/nsSigHandlers.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ramiro
|
||||
* Jerry.Kirk@Nexwarecorp.com
|
||||
*/
|
||||
|
||||
/*
|
||||
* This module is supposed to abstract signal handling away from the other
|
||||
* platforms that do not support it.
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include "prthread.h"
|
||||
|
||||
extern "C" char * strsignal(int);
|
||||
static char _progname[1024] = "huh?";
|
||||
|
||||
#ifdef DEBUG_ramiro
|
||||
#define CRAWL_STACK_ON_SIGSEGV
|
||||
#endif // DEBUG_ramiro
|
||||
|
||||
#ifdef NTO
|
||||
void abnormal_exit_handler(int signum)
|
||||
{
|
||||
/* Free any shared memory that has been allocated */
|
||||
PgShmemCleanup();
|
||||
|
||||
#if 1
|
||||
if ( (signum == SIGSEGV)
|
||||
|| (signum == SIGILL)
|
||||
|| (signum == SIGABRT)
|
||||
)
|
||||
{
|
||||
PR_CurrentThread();
|
||||
printf("prog = %s\npid = %d\nsignal = %s\n",
|
||||
_progname, getpid(), strsignal(signum));
|
||||
|
||||
printf("Sleeping for 5 minutes.\n");
|
||||
printf("Type 'gdb %s %d' to attatch your debugger to this thread.\n",
|
||||
_progname, getpid());
|
||||
|
||||
sleep(300);
|
||||
|
||||
printf("Done sleeping...\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
_exit(1);
|
||||
}
|
||||
#elif defined(CRAWL_STACK_ON_SIGSEGV)
|
||||
|
||||
#include <unistd.h>
|
||||
#include "nsTraceRefcnt.h"
|
||||
|
||||
void
|
||||
ah_crap_handler(int signum)
|
||||
{
|
||||
PR_CurrentThread();
|
||||
|
||||
printf("prog = %s\npid = %d\nsignal = %s\n",
|
||||
_progname,
|
||||
getpid(),
|
||||
strsignal(signum));
|
||||
|
||||
printf("stack logged to someplace\n");
|
||||
nsTraceRefcnt::WalkTheStack(stdout);
|
||||
|
||||
printf("Sleeping for 5 minutes.\n");
|
||||
printf("Type 'gdb %s %d' to attatch your debugger to this thread.\n",
|
||||
_progname,
|
||||
getpid());
|
||||
|
||||
sleep(300);
|
||||
|
||||
printf("Done sleeping...\n");
|
||||
}
|
||||
#endif // CRAWL_STACK_ON_SIGSEGV
|
||||
|
||||
|
||||
|
||||
void InstallUnixSignalHandlers(const char *ProgramName)
|
||||
{
|
||||
|
||||
strncpy(_progname,ProgramName, (sizeof(_progname)-1) );
|
||||
|
||||
#if defined(NTO)
|
||||
/* Neutrino need this to free shared memory in case of a crash */
|
||||
signal(SIGTERM, abnormal_exit_handler);
|
||||
signal(SIGQUIT, abnormal_exit_handler);
|
||||
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);
|
||||
#elif defined(CRAWL_STACK_ON_SIGSEGV)
|
||||
signal(SIGSEGV, ah_crap_handler);
|
||||
signal(SIGILL, ah_crap_handler);
|
||||
signal(SIGABRT, ah_crap_handler);
|
||||
#endif // CRAWL_STACK_ON_SIGSEGV
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user