Line 1... |
Line 1... |
/* Utilities to execute a program in a subprocess (possibly linked by pipes
|
/* Utilities to execute a program in a subprocess (possibly linked by pipes
|
with other subprocesses), and wait for it. Generic Unix version
|
with other subprocesses), and wait for it. Generic Unix version
|
(also used for UWIN and VMS).
|
(also used for UWIN and VMS).
|
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
|
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2009
|
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
|
|
This file is part of the libiberty library.
|
This file is part of the libiberty library.
|
Libiberty is free software; you can redistribute it and/or
|
Libiberty is free software; you can redistribute it and/or
|
modify it under the terms of the GNU Library General Public
|
modify it under the terms of the GNU Library General Public
|
Line 63... |
Line 63... |
# define VFORK_STRING "vfork"
|
# define VFORK_STRING "vfork"
|
#endif
|
#endif
|
#ifdef HAVE_VFORK_H
|
#ifdef HAVE_VFORK_H
|
#include <vfork.h>
|
#include <vfork.h>
|
#endif
|
#endif
|
#ifdef VMS
|
#if defined(VMS) && defined (__LONG_POINTERS)
|
#define vfork() (decc$$alloc_vfork_blocks() >= 0 ? \
|
#ifndef __CHAR_PTR32
|
lib$get_current_invo_context(decc$$get_vfork_jmpbuf()) : -1)
|
typedef char * __char_ptr32
|
#endif /* VMS */
|
__attribute__ ((mode (SI)));
|
|
#endif
|
|
|
|
typedef __char_ptr32 *__char_ptr_char_ptr32
|
|
__attribute__ ((mode (SI)));
|
|
|
|
/* Return a 32 bit pointer to an array of 32 bit pointers
|
|
given a 64 bit pointer to an array of 64 bit pointers. */
|
|
|
|
static __char_ptr_char_ptr32
|
|
to_ptr32 (char **ptr64)
|
|
{
|
|
int argc;
|
|
__char_ptr_char_ptr32 short_argv;
|
|
|
|
for (argc=0; ptr64[argc]; argc++);
|
|
|
|
/* Reallocate argv with 32 bit pointers. */
|
|
short_argv = (__char_ptr_char_ptr32) decc$malloc
|
|
(sizeof (__char_ptr32) * (argc + 1));
|
|
|
|
for (argc=0; ptr64[argc]; argc++)
|
|
short_argv[argc] = (__char_ptr32) decc$strdup (ptr64[argc]);
|
|
|
|
short_argv[argc] = (__char_ptr32) 0;
|
|
return short_argv;
|
|
|
|
}
|
|
#else
|
|
#define to_ptr32(argv) argv
|
|
#endif
|
|
|
/* File mode to use for private and world-readable files. */
|
/* File mode to use for private and world-readable files. */
|
|
|
#if defined (S_IRUSR) && defined (S_IWUSR) && defined (S_IRGRP) && defined (S_IWGRP) && defined (S_IROTH) && defined (S_IWOTH)
|
#if defined (S_IRUSR) && defined (S_IWUSR) && defined (S_IRGRP) && defined (S_IWGRP) && defined (S_IROTH) && defined (S_IWOTH)
|
#define PUBLIC_MODE \
|
#define PUBLIC_MODE \
|
Line 423... |
Line 452... |
if (env)
|
if (env)
|
environ = (char**) env;
|
environ = (char**) env;
|
|
|
if ((flags & PEX_SEARCH) != 0)
|
if ((flags & PEX_SEARCH) != 0)
|
{
|
{
|
execvp (executable, argv);
|
execvp (executable, to_ptr32 (argv));
|
pex_child_error (obj, executable, "execvp", errno);
|
pex_child_error (obj, executable, "execvp", errno);
|
}
|
}
|
else
|
else
|
{
|
{
|
execv (executable, argv);
|
execv (executable, to_ptr32 (argv));
|
pex_child_error (obj, executable, "execv", errno);
|
pex_child_error (obj, executable, "execv", errno);
|
}
|
}
|
|
|
/* NOTREACHED */
|
/* NOTREACHED */
|
return (pid_t) -1;
|
return (pid_t) -1;
|