Use path_exists

This commit is contained in:
Orestis Floros 2018-08-01 18:12:55 +03:00
parent 50880db2c5
commit a15fff2370
No known key found for this signature in database
GPG Key ID: E9AD9F32E401E38F
1 changed files with 2 additions and 3 deletions

View File

@ -62,14 +62,13 @@ static int sighandler_backtrace(void) {
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 dont 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) {
@ -130,7 +129,7 @@ static int sighandler_backtrace(void) {
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;
}