mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-15 14:01:04 +08:00
system.h (STDIN_FILENO): Provide default definition if one is not provided by the system header files.
* system.h (STDIN_FILENO): Provide default definition if one is not provided by the system header files. (STDOUT_FILENO, STDERR_FILENO): Likewise. * i386/xm-djgpp.h (COLLECT2_HOST_INITIALIZATION): New macro. * collect2.c (main): Use it. (pexecute_pid): New variable. Holds return value from call to pexecute. (collect2_execute): Rework to use pexecute instead of fork. (collect2_wait): Use pwait() instead of wait(). Co-Authored-By: Jeffrey A Law <law@cygnus.com> From-SVN: r25960
This commit is contained in:
parent
cc33944a7a
commit
f3692274cb
@ -5,7 +5,18 @@ Tue Mar 23 15:45:25 1999 Richard Earnshaw (rearnsha@arm.com)
|
||||
as we know the type. Remove now unnecessary set of orig_type for
|
||||
conversions.
|
||||
|
||||
Wed Mar 24 23:27:25 1999 Mark Elbrecht <snowball3@usa.net.
|
||||
Wed Mar 24 23:27:25 1999 Mark Elbrecht <snowball3@usa.net>
|
||||
Jeff Law <law@cygnus.com>
|
||||
|
||||
* system.h (STDIN_FILENO): Provide default definition if one is not
|
||||
provided by the system header files.
|
||||
(STDOUT_FILENO, STDERR_FILENO): Likewise.
|
||||
|
||||
* i386/xm-djgpp.h (COLLECT2_HOST_INITIALIZATION): New macro.
|
||||
* collect2.c (main): Use it.
|
||||
(pexecute_pid): New variable. Holds return value from call to pexecute.
|
||||
(collect2_execute): Rework to use pexecute instead of fork.
|
||||
(collect2_wait): Use pwait() instead of wait().
|
||||
|
||||
* i386/djgpp.h: Fix typo.
|
||||
|
||||
|
@ -225,6 +225,9 @@ struct obstack temporary_obstack;
|
||||
struct obstack permanent_obstack;
|
||||
char * temporary_firstobj;
|
||||
|
||||
/* Holds the return value of pexecute. */
|
||||
int pexecute_pid;
|
||||
|
||||
/* Defined in the automatically-generated underscore.c. */
|
||||
extern int prepends_underscore;
|
||||
|
||||
@ -999,6 +1002,11 @@ main (argc, argv)
|
||||
int first_file;
|
||||
int num_c_args = argc+9;
|
||||
|
||||
#if defined (COLLECT2_HOST_INITIALZATION)
|
||||
/* Perform system dependant initialization, if neccessary. */
|
||||
COLLECT2_HOST_INITIALZATION;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LC_MESSAGES
|
||||
setlocale (LC_MESSAGES, "");
|
||||
#endif
|
||||
@ -1661,7 +1669,7 @@ collect_wait (prog)
|
||||
{
|
||||
int status;
|
||||
|
||||
wait (&status);
|
||||
pwait (pexecute_pid, &status, 0);
|
||||
if (status)
|
||||
{
|
||||
if (WIFSIGNALED (status))
|
||||
@ -1695,7 +1703,7 @@ do_wait (prog)
|
||||
}
|
||||
|
||||
|
||||
/* Fork and execute a program, and wait for the reply. */
|
||||
/* Execute a program, and wait for the reply. */
|
||||
|
||||
void
|
||||
collect_execute (prog, argv, redir)
|
||||
@ -1703,7 +1711,11 @@ collect_execute (prog, argv, redir)
|
||||
char **argv;
|
||||
char *redir;
|
||||
{
|
||||
int pid;
|
||||
char *errmsg_fmt;
|
||||
char *errmsg_arg;
|
||||
int redir_handle = -1;
|
||||
int stdout_save = -1;
|
||||
int stderr_save = -1;
|
||||
|
||||
if (vflag || debug)
|
||||
{
|
||||
@ -1730,24 +1742,41 @@ collect_execute (prog, argv, redir)
|
||||
if (argv[0] == 0)
|
||||
fatal ("cannot find `%s'", prog);
|
||||
|
||||
pid = vfork ();
|
||||
if (pid == -1)
|
||||
fatal_perror (VFORK_STRING);
|
||||
|
||||
if (pid == 0) /* child context */
|
||||
if (redir)
|
||||
{
|
||||
if (redir)
|
||||
{
|
||||
unlink (redir);
|
||||
if (freopen (redir, "a", stdout) == NULL)
|
||||
fatal_perror ("freopen stdout %s", redir);
|
||||
if (freopen (redir, "a", stderr) == NULL)
|
||||
fatal_perror ("freopen stderr %s", redir);
|
||||
}
|
||||
/* Open response file. */
|
||||
redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT);
|
||||
|
||||
execvp (argv[0], argv);
|
||||
fatal_perror ("execvp %s", prog);
|
||||
/* Duplicate the stdout and stderr file handles
|
||||
so they can be restored later. */
|
||||
stdout_save = dup (STDOUT_FILENO);
|
||||
if (stdout_save == -1)
|
||||
fatal_perror ("redirecting stdout: %s", redir);
|
||||
stderr_save = dup (STDERR_FILENO);
|
||||
if (stderr_save == -1)
|
||||
fatal_perror ("redirecting stdout: %s", redir);
|
||||
|
||||
/* Redirect stdout & stderr to our response file. */
|
||||
dup2 (redir_handle, STDOUT_FILENO);
|
||||
dup2 (redir_handle, STDERR_FILENO);
|
||||
}
|
||||
|
||||
pexecute_pid = pexecute (argv[0], argv, argv[0], NULL,
|
||||
&errmsg_fmt, &errmsg_arg,
|
||||
(PEXECUTE_FIRST | PEXECUTE_LAST | PEXECUTE_SEARCH));
|
||||
|
||||
if (redir)
|
||||
{
|
||||
/* Restore stdout and stderr to their previous settings. */
|
||||
dup2 (stdout_save, STDOUT_FILENO);
|
||||
dup2 (stderr_save, STDERR_FILENO);
|
||||
|
||||
/* Close reponse file. */
|
||||
close (redir_handle);
|
||||
}
|
||||
|
||||
if (pexecute_pid == -1)
|
||||
fatal_perror (errmsg_fmt, errmsg_arg);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -34,3 +34,9 @@ Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define LIBSTDCXX "-lstdcxx"
|
||||
|
||||
/* System dependant initialization for collect2
|
||||
to tell system() to act like Unix. */
|
||||
#define COLLECT2_HOST_INITIALIZATION \
|
||||
do { __system_flags |= (__system_allow_multiple_cmds \
|
||||
| __system_emulate_chdir); } while (0)
|
||||
|
||||
|
11
gcc/system.h
11
gcc/system.h
@ -477,6 +477,17 @@ extern void abort ();
|
||||
#define O_NOCTTY 0
|
||||
#endif
|
||||
|
||||
/* Define well known filenos if the system does not define them. */
|
||||
#ifndef STDIN_FILENO
|
||||
# define STDIN_FILENO 0
|
||||
#endif
|
||||
#ifndef STDOUT_FILENO
|
||||
# define STDOUT_FILENO 1
|
||||
#endif
|
||||
#ifndef STDOUT_FILENO
|
||||
# define STDERR_FILENO 2
|
||||
#endif
|
||||
|
||||
/* Get libiberty declarations. */
|
||||
#include "libiberty.h"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user