/* Creation of autonomous subprocesses.
- Copyright (C) 2001-2004, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2001-2004, 2006-2008 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
- This program is free software; you can redistribute it and/or modify
+ This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include <config.h>
/* Specification. */
#include "execute.h"
#include <unistd.h>
#include "error.h"
-#include "exit.h"
#include "fatal-signal.h"
#include "wait-process.h"
#include "gettext.h"
#else
/* Unix API. */
-# ifdef HAVE_POSIX_SPAWN
+# if HAVE_POSIX_SPAWN
# include <spawn.h>
# else
-# ifdef HAVE_VFORK_H
+# if HAVE_VFORK_H
# include <vfork.h>
# endif
# endif
#endif
-#ifndef HAVE_ENVIRON_DECL
-extern char **environ;
-#endif
-
#ifndef STDIN_FILENO
# define STDIN_FILENO 0
#endif
# define STDERR_FILENO 2
#endif
+/* The results of open() in this file are not used with fchdir,
+ therefore save some unnecessary work in fchdir.c. */
+#undef open
+#undef close
+
#ifdef EINTR
const char *prog_path, char **prog_argv,
bool ignore_sigpipe,
bool null_stdin, bool null_stdout, bool null_stderr,
- bool slave_process, bool exit_on_error)
+ bool slave_process, bool exit_on_error,
+ int *termsigp)
{
#if defined _MSC_VER || defined __MINGW32__
if (null_stdin)
dup2 (orig_stdin, STDIN_FILENO), close (orig_stdin);
+ if (termsigp != NULL)
+ *termsigp = 0;
+
if (exitcode == -1)
{
if (exit_on_error || !null_stderr)
posix_spawnattr_destroy (&attrs);
if (slave_process)
unblock_fatal_signals ();
+ if (termsigp != NULL)
+ *termsigp = 0;
if (exit_on_error || !null_stderr)
error (exit_on_error ? EXIT_FAILURE : 0, err,
_("%s subprocess failed"), progname);
{
if (slave_process)
unblock_fatal_signals ();
+ if (termsigp != NULL)
+ *termsigp = 0;
if (exit_on_error || !null_stderr)
error (exit_on_error ? EXIT_FAILURE : 0, errno,
_("%s subprocess failed"), progname);
}
return wait_subprocess (child, progname, ignore_sigpipe, null_stderr,
- slave_process, exit_on_error);
+ slave_process, exit_on_error, termsigp);
#endif
}