8158629: bash >(...) construct still causes race conditions
Reviewed-by: tbell
This commit is contained in:
parent
f842de1dd2
commit
7fbf406a0e
@ -801,15 +801,20 @@ endif
|
|||||||
# of the build in case of failure. The command line itself is stored in a file,
|
# of the build in case of failure. The command line itself is stored in a file,
|
||||||
# and also logged to stdout if the LOG=cmdlines option has been given.
|
# and also logged to stdout if the LOG=cmdlines option has been given.
|
||||||
#
|
#
|
||||||
|
# NOTE: If the command redirects stdout, the caller needs to wrap it in a
|
||||||
|
# subshell (by adding parentheses around it), otherwise the redirect to the
|
||||||
|
# subshell tee process will create a race condition where the target file may
|
||||||
|
# not be fully written when the make recipe is done.
|
||||||
|
#
|
||||||
# Param 1 - The path to base the name of the log file / command line file on
|
# Param 1 - The path to base the name of the log file / command line file on
|
||||||
# Param 2 - The command to run
|
# Param 2 - The command to run
|
||||||
ExecuteWithLog = \
|
ExecuteWithLog = \
|
||||||
$(call LogCmdlines, Exececuting: [$(strip $2)]) \
|
$(call LogCmdlines, Exececuting: [$(strip $2)]) \
|
||||||
$(call WriteFile, $2, $(strip $1).cmdline) \
|
$(call WriteFile, $2, $(strip $1).cmdline) \
|
||||||
( ( $(strip $2) > >($(TEE) $(strip $1).log) 2> >($(TEE) $(strip $1).log >&2) || \
|
( $(strip $2) > >($(TEE) $(strip $1).log) 2> >($(TEE) $(strip $1).log >&2) || \
|
||||||
( exitcode=$(DOLLAR)? && \
|
( exitcode=$(DOLLAR)? && \
|
||||||
$(CP) $(strip $1).log $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(subst /,_,$(patsubst $(BUILD_OUTPUT)/%,%,$(strip $1))).log && \
|
$(CP) $(strip $1).log $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(subst /,_,$(patsubst $(BUILD_OUTPUT)/%,%,$(strip $1))).log && \
|
||||||
exit $(DOLLAR)exitcode ) ) && wait )
|
exit $(DOLLAR)exitcode ) )
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Find lib dir for module
|
# Find lib dir for module
|
||||||
|
Loading…
x
Reference in New Issue
Block a user