Improve docs
[platform/upstream/glib.git] / glib / gbacktrace.c
index 934c8ca..9ff26ee 100644 (file)
@@ -45,6 +45,9 @@
 #include <sys/times.h>
 #endif
 #include <sys/types.h>
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
 
 #include <time.h>
 #ifdef HAVE_UNISTD_H
@@ -55,9 +58,7 @@
 #include <sys/select.h>
 #endif /* HAVE_SYS_SELECT_H */
 
-#ifdef STDC_HEADERS
 #include <string.h> /* for bzero on BSD systems */
-#endif
 
 #ifdef G_OS_WIN32
 #  define STRICT               /* Strict typing, please */
@@ -89,9 +90,9 @@ void
 g_on_error_query (const gchar *prg_name)
 {
 #ifndef G_OS_WIN32
-  static const gchar *query1 = "[E]xit, [H]alt";
-  static const gchar *query2 = ", show [S]tack trace";
-  static const gchar *query3 = " or [P]roceed";
+  static const gchar * const query1 = "[E]xit, [H]alt";
+  static const gchar * const query2 = ", show [S]tack trace";
+  static const gchar * const query3 = " or [P]roceed";
   gchar buf[16];
 
   if (!prg_name)
@@ -161,6 +162,7 @@ g_on_error_stack_trace (const gchar *prg_name)
   pid_t pid;
   gchar buf[16];
   gchar *args[4] = { "gdb", NULL, NULL, NULL };
+  int status;
 
   if (!prg_name)
     return;
@@ -181,10 +183,8 @@ g_on_error_stack_trace (const gchar *prg_name)
       perror ("unable to fork gdb");
       return;
     }
-  
-  while (glib_on_error_halt)
-    ;
-  glib_on_error_halt = TRUE;
+
+  waitpid (pid, &status, 0);
 #else
   if (IsDebuggerPresent ())
     G_BREAKPOINT ();