aboutsummaryrefslogtreecommitdiffhomepage
path: root/uzbl.c
diff options
context:
space:
mode:
authorGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-05-03 11:08:57 +0200
committerGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-05-03 11:08:57 +0200
commit0536ddbc7d0b2b749664ec148d6a1d3be5973390 (patch)
tree7547ca5e0cf33a3a2e680ab95d9c5225341c064c /uzbl.c
parent4292e53ea63500978bdb0594cd9c4ee96cc4dd69 (diff)
somewhat improved fifo code. bug still not fixed
Diffstat (limited to 'uzbl.c')
-rw-r--r--uzbl.c34
1 files changed, 25 insertions, 9 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;