Commit af475972 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Fix #357585, Padraig O'Briain.

2006-12-15  Matthias Clasen  <mclasen@redhat.com>

	Fix #357585, Padraig O'Briain.

	* configure.in: Check for fdwalk.

	* glib/gspawn.c (do_exec): Use fdwalk() to close all
	file descriptors.

	* glib/gspawn.c (fdwalk): Fallback implementation of
	fdwalk.
parent 0fffe4ab
2006-12-15 Matthias Clasen <mclasen@redhat.com>
Fix #357585, Padraig O'Briain.
* configure.in: Check for fdwalk.
* glib/gspawn.c (do_exec): Use fdwalk() to close all
file descriptors.
* glib/gspawn.c (fdwalk): Fallback implementation of
fdwalk.
2006-12-14 Matthias Clasen <mclasen@redhat.com>
* glib/gconvert.c (open_converter): Don't use alloca
......
......@@ -855,7 +855,7 @@ fi
AC_MSG_RESULT(unsigned $glib_size_type)
# Check for some functions
AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf stpcpy strcasecmp strncasecmp poll getcwd vasprintf setenv unsetenv getc_unlocked readlink symlink)
AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf stpcpy strcasecmp strncasecmp poll getcwd vasprintf setenv unsetenv getc_unlocked readlink symlink fdwalk)
# Check for high-resolution sleep functions
AC_CHECK_FUNCS(nanosleep nsleep)
......
......@@ -30,6 +30,7 @@
#include <fcntl.h>
#include <signal.h>
#include <string.h>
#include <stdlib.h> /* for fdwalk */
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
......@@ -850,11 +851,29 @@ write_err_and_exit (gint fd, gint msg)
}
static void
set_cloexec (gint fd)
set_cloexec (void *data, gint fd)
{
fcntl (fd, F_SETFD, FD_CLOEXEC);
if (fd > 2)
fcntl (fd, F_SETFD, FD_CLOEXEC);
}
#ifndef HAVE_FDWALK
static int
fdwalk (int (*cb)(void *data, int fd), void *data)
{
gint open_max;
gint fd;
gint res;
res = 0;
open_max = sysconf (_SC_OPEN_MAX);
for (fd = 0; fd < open_max && res == 0; fd++)
res = cb (data, fd);
return res;
}
#endif
static gint
sane_dup2 (gint fd1, gint fd2)
{
......@@ -904,12 +923,7 @@ do_exec (gint child_err_report_fd,
*/
if (close_descriptors)
{
gint open_max;
gint i;
open_max = sysconf (_SC_OPEN_MAX);
for (i = 3; i < open_max; i++)
set_cloexec (i);
fdwalk (set_cloexec, NULL);
}
else
{
......
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