|
|
@ -57,17 +57,17 @@
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
KCrash::HandlerType KCrash::_emergencySaveFunction = 0;
|
|
|
|
TDECrash::HandlerType TDECrash::_emergencySaveFunction = 0;
|
|
|
|
KCrash::HandlerType KCrash::_crashHandler = 0;
|
|
|
|
TDECrash::HandlerType TDECrash::_crashHandler = 0;
|
|
|
|
const char *KCrash::appName = 0;
|
|
|
|
const char *TDECrash::appName = 0;
|
|
|
|
const char *KCrash::appPath = 0;
|
|
|
|
const char *TDECrash::appPath = 0;
|
|
|
|
bool KCrash::safer = false;
|
|
|
|
bool TDECrash::safer = false;
|
|
|
|
|
|
|
|
|
|
|
|
// This function sets the function which should be called when the
|
|
|
|
// This function sets the function which should be called when the
|
|
|
|
// application crashes and the
|
|
|
|
// application crashes and the
|
|
|
|
// application is asked to try to save its data.
|
|
|
|
// application is asked to try to save its data.
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCrash::setEmergencySaveFunction (HandlerType saveFunction)
|
|
|
|
TDECrash::setEmergencySaveFunction (HandlerType saveFunction)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_emergencySaveFunction = saveFunction;
|
|
|
|
_emergencySaveFunction = saveFunction;
|
|
|
|
|
|
|
|
|
|
|
@ -83,7 +83,7 @@ KCrash::setEmergencySaveFunction (HandlerType saveFunction)
|
|
|
|
// This function sets the function which should be responsible for
|
|
|
|
// This function sets the function which should be responsible for
|
|
|
|
// the application crash handling.
|
|
|
|
// the application crash handling.
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCrash::setCrashHandler (HandlerType handler)
|
|
|
|
TDECrash::setCrashHandler (HandlerType handler)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
if (!handler)
|
|
|
|
if (!handler)
|
|
|
@ -116,7 +116,7 @@ KCrash::setCrashHandler (HandlerType handler)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCrash::defaultCrashHandler (int sig)
|
|
|
|
TDECrash::defaultCrashHandler (int sig)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
// WABA: Do NOT use kdDebug() in this function because it is much too risky!
|
|
|
|
// WABA: Do NOT use kdDebug() in this function because it is much too risky!
|
|
|
@ -148,10 +148,10 @@ KCrash::defaultCrashHandler (int sig)
|
|
|
|
if (appName)
|
|
|
|
if (appName)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifndef NDEBUG
|
|
|
|
#ifndef NDEBUG
|
|
|
|
fprintf(stderr, "[kcrash] KCrash: crashing... crashRecursionCounter = %d\n", crashRecursionCounter);
|
|
|
|
fprintf(stderr, "[kcrash] TDECrash: crashing... crashRecursionCounter = %d\n", crashRecursionCounter);
|
|
|
|
fprintf(stderr, "[kcrash] KCrash: Application Name = %s path = %s pid = %d\n", appName ? appName : "<unknown>" , appPath ? appPath : "<unknown>", getpid());
|
|
|
|
fprintf(stderr, "[kcrash] TDECrash: Application Name = %s path = %s pid = %d\n", appName ? appName : "<unknown>" , appPath ? appPath : "<unknown>", getpid());
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
fprintf(stderr, "[kcrash] KCrash: Application '%s' crashing...\n", appName ? appName : "<unknown>");
|
|
|
|
fprintf(stderr, "[kcrash] TDECrash: Application '%s' crashing...\n", appName ? appName : "<unknown>");
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
const char * argv[24]; // don't forget to update this
|
|
|
|
const char * argv[24]; // don't forget to update this
|
|
|
@ -254,7 +254,7 @@ static int write_socket(int sock, char *buffer, int len);
|
|
|
|
static int read_socket(int sock, char *buffer, int len);
|
|
|
|
static int read_socket(int sock, char *buffer, int len);
|
|
|
|
static int openSocket();
|
|
|
|
static int openSocket();
|
|
|
|
|
|
|
|
|
|
|
|
void KCrash::startDrKonqi( const char* argv[], int argc )
|
|
|
|
void TDECrash::startDrKonqi( const char* argv[], int argc )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int socket = openSocket();
|
|
|
|
int socket = openSocket();
|
|
|
|
if( socket < -1 )
|
|
|
|
if( socket < -1 )
|
|
|
@ -277,7 +277,7 @@ void KCrash::startDrKonqi( const char* argv[], int argc )
|
|
|
|
int len = strlen( argv[ i ] ) + 1; // include terminating \0
|
|
|
|
int len = strlen( argv[ i ] ) + 1; // include terminating \0
|
|
|
|
if( pos + len > BUFSIZE )
|
|
|
|
if( pos + len > BUFSIZE )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fprintf( stderr, "[kcrash] BUFSIZE in KCrash not big enough!\n" );
|
|
|
|
fprintf( stderr, "[kcrash] BUFSIZE in TDECrash not big enough!\n" );
|
|
|
|
startDirectly( argv, argc );
|
|
|
|
startDirectly( argv, argc );
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -315,9 +315,9 @@ void KCrash::startDrKonqi( const char* argv[], int argc )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If we can't reach tdeinit we can still at least try to fork()
|
|
|
|
// If we can't reach tdeinit we can still at least try to fork()
|
|
|
|
void KCrash::startDirectly( const char* argv[], int )
|
|
|
|
void TDECrash::startDirectly( const char* argv[], int )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fprintf( stderr, "[kcrash] KCrash cannot reach tdeinit, launching directly.\n" );
|
|
|
|
fprintf( stderr, "[kcrash] TDECrash cannot reach tdeinit, launching directly.\n" );
|
|
|
|
pid_t pid = fork();
|
|
|
|
pid_t pid = fork();
|
|
|
|
if (pid <= 0)
|
|
|
|
if (pid <= 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|