fix for blocking on open(fifo) waiting for a writer
authorDieter Plaetinck <dieter@plaetinck.be>
Sun, 3 May 2009 08:37:08 +0000 (10:37 +0200)
committerDieter Plaetinck <dieter@plaetinck.be>
Sun, 3 May 2009 08:37:08 +0000 (10:37 +0200)
uzbl.c

diff --git a/uzbl.c b/uzbl.c
index da81fb3..7e28f59 100644 (file)
--- a/uzbl.c
+++ b/uzbl.c
@@ -510,10 +510,11 @@ create_fifo() {
         printf ("Fifo: disabled.  Error when creating %s: File exists\n", fifo_path);
         return;
     }
-    if (mkfifo (fifo_path, 0666) == -1) { //TODO: mkfifo blocks (waits for writer)
+    if (mkfifo (fifo_path, 0666) == -1) {
         printf ("Fifo: disabled.  Error when creating %s: %s\n", fifo_path, strerror(errno));
     } else {
-        chan = g_io_channel_new_file((gchar *) fifo_path, "r", &error);
+        // 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);