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

 This adds SIGABRT handler to server.

 This is useful in my (somewhat) automated testing environment. I have
callback attached to freelog(). Now it can log notices about asserts
too.

 Benefit for wider audience is that it know displays BUG_URL after assert.


 - 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-08-07 13:03:22.000000000 +0300
@@ -85,7 +85,19 @@
   }
   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)
+{
+  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 +124,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