Sat, 17 Mar 2018 11:35:07 +0200
removed the old Add History Line tool
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
1072 | 3 | * Copyright (C) 2013 - 2017 Teemu Piippo |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
19 | #include <QtGlobal> |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
20 | |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
21 | #ifdef Q_OS_UNIX |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
22 | # include <QProcess> |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
23 | # include <QTemporaryFile> |
1058
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
24 | # include <signal.h> |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
25 | # include <unistd.h> |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
26 | # include "crashCatcher.h" |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
27 | |
855
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
848
diff
changeset
|
28 | # ifdef Q_OS_LINUX |
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
848
diff
changeset
|
29 | # include <sys/prctl.h> |
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
848
diff
changeset
|
30 | # endif |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | |
1058
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
32 | /* |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
33 | * finalAbort |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
34 | * |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
35 | * Removes the signal handler from SIGABRT and then aborts. |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
36 | * This really aborts instead of falling back into the crash handler. |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
37 | */ |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
38 | // |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
39 | static void finalAbort() |
778
0ed96169b8c0
- crashcatcher: don't use the bomb box at all, instead just write the crashlog and then abort for good
Santeri Piippo <crimsondusk64@gmail.com>
parents:
765
diff
changeset
|
40 | { |
0ed96169b8c0
- crashcatcher: don't use the bomb box at all, instead just write the crashlog and then abort for good
Santeri Piippo <crimsondusk64@gmail.com>
parents:
765
diff
changeset
|
41 | struct sigaction sighandler; |
0ed96169b8c0
- crashcatcher: don't use the bomb box at all, instead just write the crashlog and then abort for good
Santeri Piippo <crimsondusk64@gmail.com>
parents:
765
diff
changeset
|
42 | sighandler.sa_handler = SIG_DFL; |
0ed96169b8c0
- crashcatcher: don't use the bomb box at all, instead just write the crashlog and then abort for good
Santeri Piippo <crimsondusk64@gmail.com>
parents:
765
diff
changeset
|
43 | sighandler.sa_flags = 0; |
1058
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
44 | sigaction(SIGABRT, &sighandler, 0); |
778
0ed96169b8c0
- crashcatcher: don't use the bomb box at all, instead just write the crashlog and then abort for good
Santeri Piippo <crimsondusk64@gmail.com>
parents:
765
diff
changeset
|
45 | abort(); |
0ed96169b8c0
- crashcatcher: don't use the bomb box at all, instead just write the crashlog and then abort for good
Santeri Piippo <crimsondusk64@gmail.com>
parents:
765
diff
changeset
|
46 | } |
0ed96169b8c0
- crashcatcher: don't use the bomb box at all, instead just write the crashlog and then abort for good
Santeri Piippo <crimsondusk64@gmail.com>
parents:
765
diff
changeset
|
47 | |
1058
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
48 | /* |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
49 | * handleCrash |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
50 | * |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
51 | * Handles a crash signal. Launches gdb and gets debug info for a post-mortem. |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
52 | */ |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
53 | static void handleCrash(int signal) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | { |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
55 | static bool isActive = false; |
1058
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
56 | printf("!! Caught signal %d, launching gdb\n", signal); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
58 | if (isActive) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | { |
1058
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
60 | printf("Caught signal while crash catcher is active! Execution cannot continue.\n"); |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
61 | finalAbort(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | QTemporaryFile commandsFile; |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
65 | isActive = true; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | if (commandsFile.open()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | { |
1058
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
69 | commandsFile.write(format("attach %1\n", getpid()).toLocal8Bit()); |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
70 | commandsFile.write("backtrace full\n"); |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
71 | commandsFile.write("detach\n"); |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
72 | commandsFile.write("quit"); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | commandsFile.close(); |
1058
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
74 | |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
75 | QProcess process; |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
76 | process.start("gdb", {"-x", commandsFile.fileName()}); |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
77 | |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
78 | // Linux doesn't allow ptrace to be used on anything but direct child processes, so we need to use prctl to register an exception |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
79 | // to this to allow GDB attach to us. |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
80 | #ifdef Q_OS_LINUX |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
81 | prctl(PR_SET_PTRACER, process.pid(), 0, 0, 0); |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
82 | #endif |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
83 | |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
84 | process.waitForFinished(1000); |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
85 | QString output = process.readAllStandardOutput(); |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
86 | QString errorOutput = process.readAllStandardError(); |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
87 | QFile file {UNIXNAME "-crash.log"}; |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
88 | |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
89 | if (file.open(QIODevice::WriteOnly)) |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
90 | { |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
91 | fprint(file, format("=== Program crashed with signal %1 ===\n\n" |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
92 | "GDB stdout:\n%3\nGDB stderr:\n%4\n", signal, output, errorOutput)); |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
93 | file.close(); |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
94 | printf("Backtrace written to " UNIXNAME "-crash.log. Aborting.\n"); |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
95 | } |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
96 | else |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
97 | { |
1060
940b3e565ac3
Display error string if unable to write a crash log.
Teemu Piippo <teemu@hecknology.net>
parents:
1058
diff
changeset
|
98 | printf("Unable to write a crashlog: %s\n", file.errorString().toUtf8().constData()); |
1058
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
99 | } |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
100 | } |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
101 | else |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
102 | { |
1060
940b3e565ac3
Display error string if unable to write a crash log.
Teemu Piippo <teemu@hecknology.net>
parents:
1058
diff
changeset
|
103 | printf("Unable to write commands to temporary file: %s", commandsFile.errorString().toUtf8().constData()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
106 | finalAbort(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | |
1058
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
109 | /* |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
110 | * initializeCrashHandler |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
111 | * |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
112 | * Creates handlers for crash signals, so that we can create backtraces for them. |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
113 | */ |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
114 | void initializeCrashHandler() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | { |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
116 | // List of signals to catch and crash on |
1058
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
117 | QVector<int> signalsToCatch = { |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
118 | SIGSEGV, // segmentation fault |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
119 | SIGABRT, // abort() calls |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
120 | SIGFPE, // floating point exceptions (e.g. division by zero) |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
121 | SIGILL, // illegal instructions |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
122 | }; |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
123 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | struct sigaction sighandler; |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
125 | sighandler.sa_handler = &handleCrash; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
126 | sighandler.sa_flags = 0; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | sigemptyset (&sighandler.sa_mask); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | |
1058
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
129 | for (int signal : signalsToCatch) |
778
0ed96169b8c0
- crashcatcher: don't use the bomb box at all, instead just write the crashlog and then abort for good
Santeri Piippo <crimsondusk64@gmail.com>
parents:
765
diff
changeset
|
130 | { |
1058
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
131 | if (sigaction(signal, &sighandler, nullptr) == -1) |
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
132 | fprint(stderr, "Couldn't set signal handler %1: %2", signal, strerror(errno)); |
778
0ed96169b8c0
- crashcatcher: don't use the bomb box at all, instead just write the crashlog and then abort for good
Santeri Piippo <crimsondusk64@gmail.com>
parents:
765
diff
changeset
|
133 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | } |
778
0ed96169b8c0
- crashcatcher: don't use the bomb box at all, instead just write the crashlog and then abort for good
Santeri Piippo <crimsondusk64@gmail.com>
parents:
765
diff
changeset
|
135 | |
1058
695edd4f0411
Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents:
1014
diff
changeset
|
136 | #endif // Q_OS_UNIX |