From cd5bd15987b573a436e715e59b0c651e50534bc1 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 19 Aug 2009 12:12:06 -0400 Subject: [PATCH] Use MSG_NOSIGNAL in GSocket if it's available Even though we ignore SIGPIPE, gdb will still stop when the process receives one, which sometimes confuses people into thinking the app has crashed (eg, bug 578984, bug 590420), and is annoying anyway. So use MSG_NOSIGNAL if it's there. http://bugzilla.gnome.org/show_bug.cgi?id=591378 --- gio/gsocket.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gio/gsocket.c b/gio/gsocket.c index e216bd048..dd60e0306 100644 --- a/gio/gsocket.c +++ b/gio/gsocket.c @@ -1707,6 +1707,16 @@ g_socket_receive_from (GSocket *socket, error); } +/* Although we ignore SIGPIPE, gdb will still stop if the app receives + * one, which can be confusing and annoying. So if possible, we want + * to suppress the signal entirely. + */ +#ifdef MSG_NOSIGNAL +#define G_SOCKET_DEFAULT_SEND_FLAGS MSG_NOSIGNAL +#else +#define G_SOCKET_DEFAULT_SEND_FLAGS 0 +#endif + /** * g_socket_send: * @socket: a #GSocket @@ -1759,7 +1769,7 @@ g_socket_send (GSocket *socket, G_IO_OUT, cancellable, error)) return -1; - if ((ret = send (socket->priv->fd, buffer, size, 0)) < 0) + if ((ret = send (socket->priv->fd, buffer, size, G_SOCKET_DEFAULT_SEND_FLAGS)) < 0) { int errsv = get_socket_errno (); @@ -2681,7 +2691,7 @@ g_socket_send_message (GSocket *socket, G_IO_OUT, cancellable, error)) return -1; - result = sendmsg (socket->priv->fd, &msg, flags); + result = sendmsg (socket->priv->fd, &msg, flags | G_SOCKET_DEFAULT_SEND_FLAGS); if (result < 0) { int errsv = get_socket_errno ();