libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit d6afd8ad4eff60cca437d463fee176ff05488eb4
parent dab82f1976df6f7fbfe67e4379562b79ff01b328
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu,  9 May 2013 12:58:14 +0000

-handle SIGPIPE

Diffstat:
Msrc/examples/demo.c | 29+++++++++++++++++++++++++++++
1 file changed, 29 insertions(+), 0 deletions(-)

diff --git a/src/examples/demo.c b/src/examples/demo.c @@ -781,6 +781,34 @@ generate_page (void *cls, } +static void +catcher (int sig) +{ +} + + +/** + * setup handlers to ignore SIGPIPE. + */ +static void +ignore_sigpipe () +{ + struct sigaction oldsig; + struct sigaction sig; + + sig.sa_handler = &catcher; + sigemptyset (&sig.sa_mask); +#ifdef SA_INTERRUPT + sig.sa_flags = SA_INTERRUPT; /* SunOS */ +#else + sig.sa_flags = SA_RESTART; +#endif + if (0 != sigaction (SIGPIPE, &sig, &oldsig)) + fprintf (stderr, + "Failed to install SIGPIPE handler: %s\n", strerror (errno)); +} + + /** * Entry point to demo. Note: this HTTP server will make all * files in the current directory and its subdirectories available @@ -804,6 +832,7 @@ main (int argc, char *const *argv) "%s PORT\n", argv[0]); return 1; } + ignore_sigpipe (); magic = magic_open (MAGIC_MIME_TYPE); (void) magic_load (magic, NULL);