<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39501 >

On 07/08/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
>
>  This adds SIGABRT handler to server.

 ...

>   displays BUG_URL after assert.


 This version avoids infinite loop if freelog() is asserting.


 - ML

diff -Nurd -X.diff_ignore freeciv/server/civserver.c freeciv/server/civserver.c
--- freeciv/server/civserver.c	2007-08-04 18:36:24.000000000 +0300
+++ freeciv/server/civserver.c	2007-09-05 05:45:19.000000000 +0300
@@ -85,7 +85,27 @@
   }
   timer = renew_timer_start(timer, TIMER_USER, TIMER_ACTIVE);
 }
-#endif
+
+/**************************************************************************
+  This function is called when a SIGABRT is received.
+**************************************************************************/
+static void sigabrt_handler(int sig)
+{
+  static bool aborted_already = FALSE;
+
+  if (!aborted_already) {
+    /* This is the original abort. Make sure that this code is not
+     * executed again if it itself aborts. */
+    aborted_already = TRUE;
+
+    freelog(LOG_ERROR, _("Freeciv server aborts! "
+                         "Please report this at %s. Thank you."), BUG_URL);
+  }
+
+  exit(2);
+}
+
+#endif /* USE_INTERRUPT_HANDLERS */
 
 /**************************************************************************
  Entry point for Freeciv server.  Basically, does two things:
@@ -112,6 +132,7 @@
 
 #ifdef USE_INTERRUPT_HANDLERS
   signal(SIGINT, sigint_handler);
+  signal(SIGABRT, sigabrt_handler);
 #endif
 
   /* initialize server */
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to