aboutsummaryrefslogtreecommitdiff
path: root/gdb/infrun.c
diff options
context:
space:
mode:
authorJohn Gilmore <gnu@cygnus>1991-08-02 07:15:20 +0000
committerJohn Gilmore <gnu@cygnus>1991-08-02 07:15:20 +0000
commit3b271cf4c066187c9047742bc2d1470ffb9089ac (patch)
tree56230fb862780d52586107c3f491436cc28a4aea /gdb/infrun.c
parentfe2def4b40fc9e60a37080d524f7278f817ee92c (diff)
downloadgdb-3b271cf4c066187c9047742bc2d1470ffb9089ac.zip
gdb-3b271cf4c066187c9047742bc2d1470ffb9089ac.tar.gz
gdb-3b271cf4c066187c9047742bc2d1470ffb9089ac.tar.bz2
Roll VERSION to 3.98.1. Use path to find $SHELL in "run" command.
Diffstat (limited to 'gdb/infrun.c')
-rw-r--r--gdb/infrun.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 9e5b750..e48f761 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3,19 +3,19 @@
This file is part of GDB.
-GDB 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 1, or (at your option)
-any later version.
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
-GDB is distributed in the hope that it will be useful,
+This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GDB; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Notes on the algorithm used in wait_for_inferior to determine if we
just did a subroutine call when stepping. We have the following
@@ -148,6 +148,7 @@ extern int original_stack_limit;
#endif /* SET_STACK_LIMIT_HUGE */
extern char *getenv ();
+extern char **environ;
extern struct target_ops child_ops; /* In inftarg.c */
@@ -472,6 +473,7 @@ child_create_inferior (exec_file, allargs, env)
/* This is set to the result of setpgrp, which if vforked, will be visible
to you in the parent process. It's only used by humans for debugging. */
static int debug_setpgrp = 657473;
+ char **save_our_env;
/* The user might want tilde-expansion, and in general probably wants
the program to behave the same way as if run from
@@ -500,6 +502,11 @@ child_create_inferior (exec_file, allargs, env)
/* exec is said to fail if the executable is open. */
close_exec_file ();
+ /* Retain a copy of our environment variables, since the child will
+ replace the value of environ and if we're vforked, we have to
+ restore it. */
+ save_our_env = environ;
+
#if defined(USG) && !defined(HAVE_VFORK)
pid = fork ();
#else
@@ -547,7 +554,14 @@ child_create_inferior (exec_file, allargs, env)
for the inferior. */
call_ptrace (0, 0, 0, 0); /* "Trace me, Dr. Memory!" */
- execle (shell_file, shell_file, "-c", shell_command, (char *)0, env);
+
+ /* There is no execlpe call, so we have to set the environment
+ for our child in the global variable. If we've vforked, this
+ clobbers the parent, but environ is restored a few lines down
+ in the parent. By the way, yes we do need to look down the
+ path to find $SHELL. Rich Pixley says so, and I agree. */
+ environ = env;
+ execlp (shell_file, shell_file, "-c", shell_command, (char *)0);
fprintf (stderr, "Cannot exec %s: %s.\n", shell_file,
errno < sys_nerr ? sys_errlist[errno] : "unknown error");
@@ -555,6 +569,9 @@ child_create_inferior (exec_file, allargs, env)
_exit (0177);
}
+ /* Restore our environment in case a vforked child clob'd it. */
+ environ = save_our_env;
+
/* Now that we have a child process, make it our target. */
push_target (&child_ops);