#endif /* !VMS */
{
/* Fork the child process. */
-
- char **parent_environ;
-
run_local:
block_sigs ();
#else
- parent_environ = environ;
-
jobserver_pre_child (flags & COMMANDS_RECURSE);
child->pid = child_execute_job ((struct childbase *)child,
child->good_stdin, argv);
- environ = parent_environ; /* Restore value child may have clobbered. */
jobserver_post_child (flags & COMMANDS_RECURSE);
#endif /* !VMS */
char *cmdline = argv[0];
/* We don't have a way to pass environment to 'system',
so we need to save and restore ours, sigh... */
- char **parent_environ = environ;
+ char **parent_env = environ;
environ = child->environment;
dos_command_running = 1;
proc_return = system (cmdline);
- environ = parent_environ;
+ environ = parent_env;
execute_by_shell = 0; /* for the next time */
}
else
#if !defined(USE_POSIX_SPAWN)
- pid = vfork();
- if (pid != 0)
- return pid;
+ {
+ /* The child may clobber environ so remember ours and restore it. */
+ char **parent_env = environ;
+ pid = vfork ();
+ if (pid != 0)
+ {
+ environ = parent_env;
+ return pid;
+ }
+ }
/* We are the child. */
unblock_all_sigs ();
errno = ENOEXEC;
# else
- /* Run the program. */
+
+ /* Run the program. Don't use execvpe() as we want the search for argv[0]
+ to use the new PATH, but execvpe() searches before resetting PATH. */
environ = envp;
execvp (argv[0], argv);
!,
'--no-print-directory -j2 --jobserver-style=pipe', "#MAKE#[2]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.\n: 2\n: 1");
}
+
+ # This crashes if we use vfork and don't reset environ properly
+ run_make_test(q!
+export PATH = $(shell echo "tests:$$PATH")
+foo = $(shell echo yes)
+
+all:;echo $(foo)
+!,
+ '', "echo yes\nyes\n");
}
# If we're not using pipes for jobserver, then they are available in sub-makes