Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix delivering the QUIT message when exiting irssi #1

Open
stapelberg opened this issue May 16, 2015 · 1 comment
Open

Fix delivering the QUIT message when exiting irssi #1

stapelberg opened this issue May 16, 2015 · 1 comment

Comments

@stapelberg
Copy link
Contributor

For that, we need to implement g_io_channel_unix_get_fd on the RoubstIOChannel. See also irssi/src/core/net-disconnect.c:net_disconnect_deinit()

@stapelberg
Copy link
Contributor Author

My current approach is this:

--- i/src/core/robustio.c
+++ w/src/core/robustio.c
@@ -2,6 +2,7 @@
 // © 2015 Michael Stapelberg (see COPYING)

 #include <glib.h>
+#include <unistd.h>

 #include "common.h"
 #include "printtext.h"
@@ -56,6 +57,13 @@ GIOChannel *robust_io_channel_new(SERVER_REC *server) {
     channel = g_new0(RobustIOChannel, 1);
     iochannel = (GIOChannel *)channel;

+    // We leave the write end open forever so that the read end will never
+    // become readable.
+    int pipefd[2];
+
+    pipe(pipefd);
+
+    channel->fd = pipefd[0];
     channel->server = server;

     iochannel->is_readable = FALSE;
diff --git i/src/core/robustio.h w/src/core/robustio.h
index 8da9187..22262c5 100644
--- i/src/core/robustio.h
+++ w/src/core/robustio.h
@@ -4,6 +4,8 @@ typedef struct _RobustIOChannel RobustIOChannel;

 struct _RobustIOChannel {
     GIOChannel channel;
+    // Define |fd| for compatibility with GIOUnixChannel.
+    gint fd;
     SERVER_REC *server;
     struct t_robustsession_ctx *robustsession;
 };

But it still segfaults, and I don’t understand why:

#0  0x00007fe8e83ef9f3 in g_source_unref_internal (source=source@entry=0x1fd88a0, context=context@entry=0x1d7a2e0, have_lock=have_lock@entry=1)
    at gmain.c:2012
#1  0x00007fe8e83f0b39 in g_source_destroy_internal (source=0x1fd88a0, context=0x1d7a2e0, have_lock=0) at gmain.c:1201
#2  0x00007fe8e83f15b5 in g_source_remove (tag=69) at gmain.c:2239
#3  0x000000000049c88a in net_disconnect_remove (rec=0x1eae0f0) at net-disconnect.c:44
#4  0x000000000049cace in net_disconnect_deinit () at net-disconnect.c:135
#5  0x0000000000493498 in core_deinit () at core.c:298
#6  0x000000000042fad0 in textui_deinit () at irssi.c:261
#7  0x000000000042fca8 in main (argc=1, argv=0x7fff239461b8) at irssi.c:386

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant