Commit 6f7d8f62 authored by Stef Walter's avatar Stef Walter

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
parent b1af471a
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment