Added real animations to the Shogi animator.
[tagua.git] / src / crash.cpp
blob8f814ad11356d580111e86920472bd086a796553
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #include <QtGlobal>
12 #include "crash.h"
14 #ifdef Q_OS_UNIX
16 #include <sys/types.h>
17 #include <unistd.h>
18 #include <stdio.h>
19 #include <signal.h>
20 #include <stdlib.h>
22 static void handler(int) {
23 if(fork())
24 while(1){}
26 char command[1024];
27 const char* args[] = { "/bin/sh", "-c", command, NULL };
28 //char *term = "xterm";
29 const char* term = "kshell konsole";
30 snprintf(command, 1024,
31 "%s -e /bin/sh -c "
32 "\"echo -e \\\"\\\\33]0;SANGE & CRASHA\\\\7\\\"; "
33 "gdb attach %d\"", term, getppid());
34 execve(args[0], const_cast<char**>(args), environ);
36 kill(getppid(), 9);
40 static void handler2(int) {
41 printf("Sange & Crasha!!!!\n");
42 printf("I'm sorry, i crashed.\n");
43 printf("Now run somewhere\n");
44 printf(" gdb attach %d\n", getpid() );
45 exit(0);
48 void installCrashHander() {
49 signal(SIGSEGV,handler2);
50 signal(SIGABRT,handler2);
53 #else
55 void installCrashHander() {
58 #endif