diff options
Diffstat (limited to 'src/examples/demo.c')
-rw-r--r-- | src/examples/demo.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/examples/demo.c b/src/examples/demo.c index 8b836a0c..9bd04fee 100644 --- a/src/examples/demo.c +++ b/src/examples/demo.c | |||
@@ -781,6 +781,34 @@ generate_page (void *cls, | |||
781 | } | 781 | } |
782 | 782 | ||
783 | 783 | ||
784 | static void | ||
785 | catcher (int sig) | ||
786 | { | ||
787 | } | ||
788 | |||
789 | |||
790 | /** | ||
791 | * setup handlers to ignore SIGPIPE. | ||
792 | */ | ||
793 | static void | ||
794 | ignore_sigpipe () | ||
795 | { | ||
796 | struct sigaction oldsig; | ||
797 | struct sigaction sig; | ||
798 | |||
799 | sig.sa_handler = &catcher; | ||
800 | sigemptyset (&sig.sa_mask); | ||
801 | #ifdef SA_INTERRUPT | ||
802 | sig.sa_flags = SA_INTERRUPT; /* SunOS */ | ||
803 | #else | ||
804 | sig.sa_flags = SA_RESTART; | ||
805 | #endif | ||
806 | if (0 != sigaction (SIGPIPE, &sig, &oldsig)) | ||
807 | fprintf (stderr, | ||
808 | "Failed to install SIGPIPE handler: %s\n", strerror (errno)); | ||
809 | } | ||
810 | |||
811 | |||
784 | /** | 812 | /** |
785 | * Entry point to demo. Note: this HTTP server will make all | 813 | * Entry point to demo. Note: this HTTP server will make all |
786 | * files in the current directory and its subdirectories available | 814 | * files in the current directory and its subdirectories available |
@@ -804,6 +832,7 @@ main (int argc, char *const *argv) | |||
804 | "%s PORT\n", argv[0]); | 832 | "%s PORT\n", argv[0]); |
805 | return 1; | 833 | return 1; |
806 | } | 834 | } |
835 | ignore_sigpipe (); | ||
807 | magic = magic_open (MAGIC_MIME_TYPE); | 836 | magic = magic_open (MAGIC_MIME_TYPE); |
808 | (void) magic_load (magic, NULL); | 837 | (void) magic_load (magic, NULL); |
809 | 838 | ||