Re: g_io_channel_write_chars() and closed socket



i've noticed this happen on linux before - it seems the kernel sends the process a SIGPIPE if the socket gets unexpectedly closed. easy fix is to do:
signal(SIGPIPE, SIG_IGN);
near the beginning of your main() function (you'll need to include signal.h). this will cause your app to ignore the PIPE signal, and not quit. make sure you check for any errors returned from g_io_channel_write_chars() to see if the write succeeded or failed.

   -brian

Fabien Penso wrote:

Hi everyone.

I have tried to find a way to fix that problem with no luck at all. This
is a simple server, you connect to it with `telnet localhost 10202` and
it prints a text. If you quit telnet with CTRL SHIFT 5, the server quits
with SIGPIPE :

Program received signal SIGPIPE, Broken pipe.
0x4010d908 in write () from /lib/libc.so.6
(gdb) bt
#0  0x4010d908 in write () from /lib/libc.so.6
#1  0x401f3398 in g_io_watch_funcs () from /usr/lib/libglib-2.0.so.0
#2  0x40196701 in g_io_channel_write_chars () from /usr/lib/libglib-2.0.so.0
#3  0x08048abc in BxSr_sendline (buffer=0x8048caa "something to say\n") at server.c:55
#4  0x08048a3c in main (argc=1, argv=0xbffff9a4) at server.c:36

Is there a way to know the client quited ? I don't see anyway (and I
don't want to use signal().

Any links/urls would be appreciated.

------------------------------------------------------------------------


------------------------------------------------------------------------

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]