diff options
-rw-r--r-- | uzbl.c | 34 | ||||
-rw-r--r-- | uzbl.h | 2 |
2 files changed, 26 insertions, 10 deletions
@@ -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; @@ -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(); |