Check if cmd exist before xstrdup it in mousebind_section and remove fifo if it exists before init

This commit is contained in:
Martin Duquesnoy 2012-01-20 20:29:58 +01:00
parent ade67b66ee
commit 545b1a2a7e
3 changed files with 15 additions and 5 deletions

View File

@ -14,8 +14,9 @@
static void
config_mouse_section(struct mbhead *mousebinds, struct conf_sec **sec)
{
int i = 0;
struct mousebind *m;
int i = 0;
char *p;
SLIST_INIT(mousebinds);
@ -25,7 +26,10 @@ config_mouse_section(struct mbhead *mousebinds, struct conf_sec **sec)
m->button = fetch_opt_first(sec[i], "1", "button").num;
m->func = uicb_name_func(fetch_opt_first(sec[i], "", "func").str);
m->cmd = xstrdup(fetch_opt_first(sec[i], "", "cmd").str);
if((p = fetch_opt_first(sec[i], "", "cmd").str))
m->cmd = xstrdup(p);
m->use_area = false;
SLIST_INSERT_HEAD(mousebinds, m, next);

View File

@ -4,6 +4,8 @@
* For license, see COPYING.
*/
#include <sys/stat.h> /* access */
#include "wmfs.h"
#include "util.h"
#include "config.h"
@ -24,6 +26,10 @@ fifo_init(void)
{
xasprintf(&(W->fifo.path), "%s/wmfs-%s.fifo", P_tmpdir, DisplayString(W->dpy));
/* Check if fifo already exists */
if(access(W->fifo.path, F_OK) != -1)
unlink(W->fifo.path);
if(mkfifo(W->fifo.path, 0644) < 0)
warnx("Can't create FIFO: %s\n", strerror(errno));