Przeglądaj źródła

-nicer error handling in example

Christian Grothoff 12 lat temu
rodzic
commit
2c646f956f
1 zmienionych plików z 9 dodań i 2 usunięć
  1. 9 2
      doc/examples/sessions.c

+ 9 - 2
doc/examples/sessions.c

@@ -12,7 +12,7 @@
 #include <microhttpd.h>
 
 #ifdef _WIN32
-int
+static int
 asprintf (char **resultp, const char *format, ...)
 {
   va_list argptr;
@@ -758,7 +758,14 @@ main (int argc, char *const *argv)
 	}
       else
 	tvp = NULL;
-      select (max + 1, &rs, &ws, &es, tvp);
+      if (-1 == select (max + 1, &rs, &ws, &es, tvp))
+	{
+	  if (EINTR != errno)
+	    fprintf (stderr, 
+		     "Aborting due to error during select: %s\n",
+		     strerror (errno));
+	  break;
+	}
       MHD_run (d);
     }
   MHD_stop_daemon (d);