summaryrefslogtreecommitdiff
path: root/function.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2013-09-29 21:57:22 -0400
committerPaul Smith <psmith@gnu.org>2013-09-30 00:12:36 -0400
commit8e12202870d40488cc5899254e227d8038433839 (patch)
tree26f8d0601a8c8ee949416f19e0f886254526090d /function.c
parent1f4ca0539b32b3f80d5aff2f096e9aebbca5300d (diff)
downloadgunmake-8e12202870d40488cc5899254e227d8038433839.tar.gz
Final fixes for obscure output-sync errors.
Diffstat (limited to 'function.c')
-rw-r--r--function.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/function.c b/function.c
index b8b9cf3..ce60ef5 100644
--- a/function.c
+++ b/function.c
@@ -1620,7 +1620,7 @@ char *
func_shell_base (char *o, char **argv, int trim_newlines)
{
char *batch_filename = NULL;
-
+ int errfd;
#ifdef __MSDOS__
FILE *fpipe;
#endif
@@ -1636,9 +1636,9 @@ func_shell_base (char *o, char **argv, int trim_newlines)
are used to run the commands, because we normally refrain from
creating batch files under -n. */
int j_p_f = just_print_flag;
-
just_print_flag = 0;
#endif
+
/* Construct the argument list. */
command_argv = construct_command_argv (argv[0], NULL, NULL, 0,
&batch_filename);
@@ -1655,7 +1655,7 @@ func_shell_base (char *o, char **argv, int trim_newlines)
export var = $(shell echo foobie)
bad := $(var)
because target_environment hits a loop trying to expand $(var) to put it
- in the environment. This is even more confusing when var was not
+ in the environment. This is even more confusing when 'var' was not
explicitly exported, but just appeared in the calling environment.
See Savannah bug #10593.
@@ -1678,6 +1678,9 @@ func_shell_base (char *o, char **argv, int trim_newlines)
/* Set up the output in case the shell writes something. */
output_start ();
+ errfd = (output_context && output_context->err >= 0
+ ? output_context->err : FD_STDERR);
+
#if defined(__MSDOS__)
fpipe = msdos_openpipe (pipedes, &pid, argv[0]);
if (pipedes[0] < 0)
@@ -1710,7 +1713,7 @@ func_shell_base (char *o, char **argv, int trim_newlines)
CLOSE_ON_EXEC(pipedes[1]);
CLOSE_ON_EXEC(pipedes[0]);
/* Never use fork()/exec() here! Use spawn() instead in exec_command() */
- pid = child_execute_job (FD_STDIN, pipedes[1], FD_STDERR, command_argv, envp);
+ pid = child_execute_job (FD_STDIN, pipedes[1], errfd, command_argv, envp);
if (pid < 0)
perror_with_name (error_prefix, "spawn");
# else /* ! __EMX__ */
@@ -1724,9 +1727,7 @@ func_shell_base (char *o, char **argv, int trim_newlines)
if (stack_limit.rlim_cur)
setrlimit (RLIMIT_STACK, &stack_limit);
# endif
- child_execute_job (FD_STDIN, pipedes[1],
- output_context ? output_context->err : FD_STDERR,
- command_argv, envp);
+ child_execute_job (FD_STDIN, pipedes[1], errfd, command_argv, envp);
}
else
# endif