summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hofmann <scm@uninformativ.de>2014-06-15 06:42:30 +0200
committerPeter Hofmann <scm@uninformativ.de>2014-06-15 06:44:42 +0200
commit251b68114afe0033b36ade299ff2a72466f97652 (patch)
tree484258349401acb27da5d761be32861bda41c169
parent31a999fd174144b107cc9e2a0e09100bbbdc938d (diff)
downloadlariza-251b68114afe0033b36ade299ff2a72466f97652.tar.gz
Do not hardcode the path to the FIFO
-rw-r--r--zea.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/zea.c b/zea.c
index 5594aee..94e7454 100644
--- a/zea.c
+++ b/zea.c
@@ -13,7 +13,6 @@
#define DOWNLOAD_DIR "/tmp/tmp"
-#define ZEA_FIFO "/tmp/zea.fifo"
#define ZEA_LANGUAGE "en-US"
@@ -359,27 +358,33 @@ void
zea_setup_cooperation(void)
{
GIOChannel *towatch;
+ gchar *fifopath;
- if (!g_file_test(ZEA_FIFO, G_FILE_TEST_EXISTS))
- mkfifo(ZEA_FIFO, 0600);
+ fifopath = g_build_filename(g_get_user_runtime_dir(), "zea.fifo", NULL);
- cooperative_pipe_fp = open(ZEA_FIFO, O_WRONLY | O_NONBLOCK);
+ if (!g_file_test(fifopath, G_FILE_TEST_EXISTS))
+ mkfifo(fifopath, 0600);
+
+ cooperative_pipe_fp = open(fifopath, O_WRONLY | O_NONBLOCK);
if (!cooperative_pipe_fp)
{
fprintf(stderr, "zea: Can't open FIFO at all.\n");
- return;
}
-
- if (write(cooperative_pipe_fp, "", 0) == -1)
+ else
{
- /* Could not do an empty write to the FIFO which means there's
- * no one listening. */
- close(cooperative_pipe_fp);
- towatch = g_io_channel_new_file(ZEA_FIFO, "r+", NULL);
- g_io_add_watch(towatch, G_IO_IN, (GIOFunc)zea_remote_msg, NULL);
+ if (write(cooperative_pipe_fp, "", 0) == -1)
+ {
+ /* Could not do an empty write to the FIFO which means there's
+ * no one listening. */
+ close(cooperative_pipe_fp);
+ towatch = g_io_channel_new_file(fifopath, "r+", NULL);
+ g_io_add_watch(towatch, G_IO_IN, (GIOFunc)zea_remote_msg, NULL);
+ }
+ else
+ alone = FALSE;
}
- else
- alone = FALSE;
+
+ g_free(fifopath);
}
void