mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
Merge branch 'gbacktrace_dup2_proper_handling' into 'master'
glib/gbacktrace.c: Handling properly the dup(stderr) call Closes #1880 See merge request GNOME/glib!1055
This commit is contained in:
commit
0d54f00317
@ -293,7 +293,8 @@ stack_trace (const char * const *args)
|
||||
{
|
||||
/* Save stderr for printing failure below */
|
||||
int old_err = dup (2);
|
||||
fcntl (old_err, F_SETFD, fcntl (old_err, F_GETFD) | FD_CLOEXEC);
|
||||
if (old_err != -1)
|
||||
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 */
|
||||
@ -302,7 +303,11 @@ stack_trace (const char * const *args)
|
||||
execvp (args[0], (char **) args); /* exec gdb */
|
||||
|
||||
/* Print failure to original stderr */
|
||||
close (2); dup (old_err);
|
||||
if (old_err != -1)
|
||||
{
|
||||
close (2);
|
||||
dup (old_err);
|
||||
}
|
||||
perror ("exec gdb failed");
|
||||
_exit (0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user