aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--uzbl.c34
-rw-r--r--uzbl.h2
2 files changed, 26 insertions, 10 deletions
diff --git a/uzbl.c b/uzbl.c
index 7e28f59..c28b18c 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -490,13 +490,26 @@ build_stream_name(int type) {
}
static void
-control_fifo(GIOChannel *fd) {
+control_fifo(GIOChannel *gio, GIOCondition condition) {
+ printf("triggered\n");
gchar *ctl_line;
- if(!fd)
- return;
- g_io_channel_read_line(fd, &ctl_line, NULL, NULL, NULL);
+ GIOStatus ret;
+ GError *err = NULL;
+
+ if (condition & G_IO_HUP)
+ g_error ("Fifo: Read end of pipe died!\n");
+
+ if(!gio)
+ g_error ("Fifo: GIOChannel broke\n");
+
+ ret = g_io_channel_read_line(gio, &ctl_line, NULL, NULL, &err);
+ if (ret == G_IO_STATUS_ERROR)
+ g_error ("Fifo: Error reading: %s\n", err->message);
+
+
parse_line(ctl_line);
g_free(ctl_line);
+ printf("...done\n");
return;
}
@@ -507,19 +520,22 @@ create_fifo() {
build_stream_name(FIFO);
if (file_exists(fifo_path)) {
- printf ("Fifo: disabled. Error when creating %s: File exists\n", fifo_path);
+ g_error ("Fifo: Error when creating %s: File exists\n", fifo_path);
return;
}
if (mkfifo (fifo_path, 0666) == -1) {
- printf ("Fifo: disabled. Error when creating %s: %s\n", fifo_path, strerror(errno));
+ g_error ("Fifo: Error when creating %s: %s\n", fifo_path, strerror(errno));
} else {
// we don't really need to write to the file, but if we open the file as 'r' we will block here, waiting for a writer to open the file.
chan = g_io_channel_new_file((gchar *) fifo_path, "r+", &error);
if (chan) {
- printf ("Fifo: created successfully as %s\n", fifo_path);
- g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_fifo, chan);
+ if (!g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_fifo, NULL)) {
+ g_error ("Fifo: could not add watch on %s\n", fifo_path);
+ } else {
+ printf ("Fifo: created successfully as %s\n", fifo_path);
+ }
} else {
- g_error ("Fifo: error while opening: %s\n", error->message);
+ g_error ("Fifo: Error while opening: %s\n", error->message);
}
}
return;
diff --git a/uzbl.h b/uzbl.h
index 652f2f0..d0d6ec7 100644
--- a/uzbl.h
+++ b/uzbl.h
@@ -83,7 +83,7 @@ void
build_stream_name(int type);
static void
-control_fifo(GIOChannel *fd);
+control_fifo(GIOChannel *gio, GIOCondition condition);
static void
create_fifo();