SIGPIPE from gnutls_bye on closed socket, error handling

Rupert Kittinger-Sereinig rks at
Sat Jan 8 13:14:55 CET 2011

Jos Kuijpers wrote:
> Folks,
> Since a week, I am having serious problems with the GnuTLS library
> concerning the gnutls_bye():
> I am writing a binding between gnutls and ObjFW
> ( =>
> When an attempt to reading from the socket failed, and results in a closed
> socket (because of a malicious client, or lost network connection, etc),
> the close method of the object gets called. This method then will call
> gnutls_bye, socket close and gnutls_deinit.
> There is the problem. Gnutls_bye sends data. When the socket is broken, and
> gnutls_bye is called, my program DIES: SIGPIPE.
> I am very disappointed about this. Catching signals in a library is
> not-done.
> Is there a way to get proper error handling done in this case? Can this be
> added? The library is unstable now, because a closed socket exits the
> server,
> which is a very bad thing.
> With kind regards,
> Jos

Hi Jos,

you can (and should) "turn off" this signal in the main application,
e.g. with sigaction().

However, if you do not know this, you should probably read some basic
book about system and network programming.


Rupert Kittinger-Sereinig <rks at>
Krenngasse 32
A-8010 Graz

More information about the Gnutls-devel mailing list