home · contact · privacy
err_exit() now prints errno message, too.
[plomrogue] / src / rexit.c
index 73d740ba4bd8e8d4e55809758dc9b1d000818dea..cb69ccd842c9275f41067e6704ae523bea9dfa60 100644 (file)
@@ -2,13 +2,14 @@
 
 #include "rexit.h"
 #include <stdlib.h> /* for exit(), free(), defines EXIT_SUCESS, EXIT_FAILURE */
-#include <stdio.h> /* for printf() */
+#include <stdio.h> /* for printf(), perror() */
 #include <stdint.h> /* for uint8_t */
 #include <ncurses.h> /* for endwin() */
 #include "main.h" /* for World struct */
 #include "map.h" /* for Map struct */
 #include "keybindings.h" /* for KeysWinData, KeyBinding structs */
 
+#include "errno.h"
 
 
 /* The clean-up routine and the flag resource by which it decides what to do. */
@@ -67,6 +68,12 @@ extern void exit_err(uint8_t err, struct World * world, char * msg)
         return;
     }
     cleanup(world);
+    if (NULL == msg)
+    {
+        msg = "Some error encountered. Aborted.";
+    }
     printf("%s\n", msg);
+    errno = 0;
+    perror("errno states");
     exit(EXIT_FAILURE);
 }