char *filename = NULL;
int suffix = 0;
- struct stat bt;
/* Find a unique filename for the backtrace (since the PID of i3 stays the
* same), so that we don’t overwrite earlier backtraces. */
do {
FREE(filename);
sasprintf(&filename, "%s/i3-backtrace.%d.%d.txt", tmpdir, pid_parent, suffix);
suffix++;
- } while (stat(filename, &bt) == 0);
+ } while (path_exists(filename));
pid_t pid_gdb = fork();
if (pid_gdb < 0) {
/* We provide pipe file descriptors for stdin/stdout because gdb < 7.5
* crashes otherwise, see
- * http://sourceware.org/bugzilla/show_bug.cgi?id=14114 */
+ * https://sourceware.org/bugzilla/show_bug.cgi?id=14114 */
dup2(stdin_pipe[0], STDIN_FILENO);
dup2(stdout_pipe[1], STDOUT_FILENO);
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
DLOG("GDB did not run properly\n");
return -1;
- } else if (stat(filename, &bt) == -1) {
+ } else if (!path_exists(filename)) {
DLOG("GDB executed successfully, but no backtrace was generated\n");
return -1;
}
}
}
-void handle_signal(int sig, siginfo_t *info, void *data) {
+static void handle_signal(int sig, siginfo_t *info, void *data) {
DLOG("i3 crashed. SIG: %d\n", sig);
struct sigaction action;
action.sa_handler = SIG_DFL;
+ action.sa_flags = 0;
+ sigemptyset(&action.sa_mask);
sigaction(sig, &action, NULL);
raised_signal = sig;