Handle execvp error in open_browser

The execvp function usually doesn't return and exits by itself. But,
when having an error, it returns. As a faulty browser setting could
trigger this, dunst has to handle this, as the forked child wants to
access the X11 server too, resulting in XIO errors.

Fixes #476
This commit is contained in:
Benedikt Heine 2018-01-13 15:04:30 +01:00
parent f7cf5b6f5b
commit b209d06963

View File

@ -119,6 +119,12 @@ void open_browser(const char *in)
string_append(settings.browser, url, " "); string_append(settings.browser, url, " ");
char **cmd = g_strsplit(browser_cmd, " ", 0); char **cmd = g_strsplit(browser_cmd, " ", 0);
execvp(cmd[0], cmd); execvp(cmd[0], cmd);
// execvp won't return if it's successful
// so, if we're here, it's definitely an error
fprintf(stderr, "Warning: failed to execute '%s': %s\n",
settings.browser,
strerror(errno));
exit(EXIT_FAILURE);
} }
} }
} }