gbacktrace: Use g_unix_open_pipe_internal () for creating pipes

This attempts to create the pipes with race-free setting of the
close-on-exec flag.
This commit is contained in:
Maciej S. Szmigiero 2023-02-19 14:44:28 +01:00 committed by Philip Withnall
parent 14b5207bfa
commit 05d2a1d097

View File

@ -45,6 +45,7 @@
#include <time.h>
#ifdef G_OS_UNIX
#include "glib-unixprivate.h"
#include <errno.h>
#include <unistd.h>
#include <sys/wait.h>
@ -397,7 +398,8 @@ stack_trace (const char * const *args)
stack_trace_done = FALSE;
signal (SIGCHLD, stack_trace_sigchld);
if ((pipe (in_fd) == -1) || (pipe (out_fd) == -1))
if (!g_unix_open_pipe_internal (in_fd, TRUE) ||
!g_unix_open_pipe_internal (out_fd, TRUE))
{
perror ("unable to open pipe");
_exit (0);