diff --git a/src/callbacks.c b/src/callbacks.c index 8f3b023b..2b302825 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -101,6 +101,11 @@ gint destroyapp(GtkWidget *widget, gpointer gdata) { gchar *fifo = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, GEANY_FIFO_NAME, NULL); // delete the fifo early, because we don't accept new files anymore + if (app->fifo_ioc != NULL) + { + g_io_channel_unref(app->fifo_ioc); + g_io_channel_shutdown(app->fifo_ioc, FALSE, NULL); + } unlink(fifo); g_free(fifo); } diff --git a/src/geany.h b/src/geany.h index 9de66dda..2254d223 100644 --- a/src/geany.h +++ b/src/geany.h @@ -60,7 +60,7 @@ #define GEANY_HOME_DIR g_get_home_dir() #define GEANY_FILEDEFS_SUBDIR "filedefs" #define GEANY_FIFO_NAME "geany_fifo.0" -#define GEANY_CODENAME "Ravik" +#define GEANY_CODENAME "Kadir" #define GEANY_HOMEPAGE "http://geany.uvena.de/" #define GEANY_MAX_OPEN_FILES 25 #define GEANY_SESSION_FILES 25 @@ -159,6 +159,7 @@ typedef struct MyApp gint long_line_column; #ifdef HAVE_FIFO gboolean ignore_fifo; + GIOChannel *fifo_ioc; #endif #ifdef HAVE_VTE gboolean load_vte; diff --git a/src/main.c b/src/main.c index f80f8a54..1de36a4b 100644 --- a/src/main.c +++ b/src/main.c @@ -335,8 +335,10 @@ static gboolean read_fifo(GIOChannel *source, GIOCondition condition, gpointer d return TRUE; else { - GIOChannel *ioc = g_io_channel_unix_new(open(fifo_name, O_RDONLY | O_NONBLOCK)); - g_io_add_watch(ioc, G_IO_IN | G_IO_PRI, read_fifo, NULL); + g_io_channel_unref(app->fifo_ioc); + g_io_channel_shutdown(app->fifo_ioc, FALSE, NULL); + app->fifo_ioc = g_io_channel_unix_new(open(fifo_name, O_RDONLY | O_NONBLOCK)); + g_io_add_watch(app->fifo_ioc, G_IO_IN | G_IO_PRI, read_fifo, NULL); return FALSE; } } @@ -362,7 +364,7 @@ static void write_fifo(gint argc, gchar **argv) /* creates a named pipe in GEANY_FIFO_NAME, to communicate with new instances of Geany * to submit filenames and possibly other things */ -static void create_fifo(gint argc, gchar **argv, const gchar *config_dir) +static GIOChannel *create_fifo(gint argc, gchar **argv, const gchar *config_dir) { struct stat st; gchar *tmp; @@ -400,11 +402,13 @@ static void create_fifo(gint argc, gchar **argv, const gchar *config_dir) if ((mkfifo(fifo_name, S_IRUSR | S_IWUSR)) == -1) { if (errno != EEXIST) geany_debug("creating of a named pipe for IPC failed! (%s)", g_strerror(errno)); - return; + return NULL; } ioc = g_io_channel_unix_new(open(fifo_name, O_RDONLY | O_NONBLOCK)); g_io_add_watch(ioc, G_IO_IN | G_IO_PRI, read_fifo, NULL); + + return ioc; } #endif @@ -413,6 +417,9 @@ gint main(gint argc, gchar **argv) { GError *error = NULL; GOptionContext *context; +#ifdef HAVE_FIFO + GIOChannel *ioc = NULL; +#endif gint mkdir_result = 0; gint idx; gchar *config_dir; @@ -454,7 +461,7 @@ gint main(gint argc, gchar **argv) } #ifdef HAVE_FIFO - if (! ignore_fifo) create_fifo(argc, argv, config_dir); + if (! ignore_fifo) ioc = create_fifo(argc, argv, config_dir); #endif g_free(config_dir); @@ -474,7 +481,9 @@ gint main(gint argc, gchar **argv) app->have_vte = app->load_vte; if (no_vte) app->have_vte = FALSE; #endif - +#ifdef HAVE_FIFO + app->fifo_ioc = ioc; +#endif filetypes_init_types(); configuration_read_filetype_extensions();