[glib] gbacktrace: Print out gdb exec errors correctly
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gbacktrace: Print out gdb exec errors correctly
- Date: Tue, 19 Nov 2013 13:54:18 +0000 (UTC)
commit 6f7d8f6294da1c08d918b14cb012e5fa854ff080
Author: Stef Walter <stefw gnome org>
Date: Tue Oct 29 18:03:29 2013 +0100
gbacktrace: Print out gdb exec errors correctly
We want to see error messages related to starting and running
gdb (such as if it's not installed).
https://bugzilla.gnome.org/show_bug.cgi?id=711088
glib/gbacktrace.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/glib/gbacktrace.c b/glib/gbacktrace.c
index 4d19d6f..9117804 100644
--- a/glib/gbacktrace.c
+++ b/glib/gbacktrace.c
@@ -64,6 +64,8 @@
# define _WIN32_WINDOWS 0x0401 /* to get IsDebuggerPresent */
# include <windows.h>
# undef STRICT
+#else
+# include <fcntl.h>
#endif
#include "gbacktrace.h"
@@ -298,12 +300,19 @@ stack_trace (char **args)
pid = fork ();
if (pid == 0)
{
+ /* Save stderr for printing failure below */
+ int old_err = dup (2);
+ fcntl (old_err, F_SETFD, fcntl (old_err, F_GETFD) | FD_CLOEXEC);
+
close (0); dup (in_fd[0]); /* set the stdin to the in pipe */
close (1); dup (out_fd[1]); /* set the stdout to the out pipe */
close (2); dup (out_fd[1]); /* set the stderr to the out pipe */
execvp (args[0], args); /* exec gdb */
- perror ("exec failed");
+
+ /* Print failure to original stderr */
+ close (2); dup (old_err);
+ perror ("exec gdb failed");
_exit (0);
}
else if (pid == (pid_t) -1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]