clean child stderr; need sort out
This commit is contained in:
+25
-10
@@ -290,7 +290,6 @@ function dump_failure {
|
|||||||
function save_err_trace_to_main {
|
function save_err_trace_to_main {
|
||||||
miaou_debug "<save_stacktrace_to_stderr count=${#error_source[@]} to=${MIAOU_BASH_ERROR_CHILDREN}>"
|
miaou_debug "<save_stacktrace_to_stderr count=${#error_source[@]} to=${MIAOU_BASH_ERROR_CHILDREN}>"
|
||||||
local i source lineno funcname
|
local i source lineno funcname
|
||||||
for i in "${tmp_error[@]}"; do >>"$MIAOU_BASH_ERROR_CHILDREN" echo "$i"; done
|
|
||||||
for i in "${!error_source[@]}"; do
|
for i in "${!error_source[@]}"; do
|
||||||
source="${error_source[$i]}"
|
source="${error_source[$i]}"
|
||||||
lineno="${error_lineno[$i]}"
|
lineno="${error_lineno[$i]}"
|
||||||
@@ -298,6 +297,7 @@ function save_err_trace_to_main {
|
|||||||
miaou_debug "<trace source=${source} lineno=${lineno} funcname=${funcname}/>"
|
miaou_debug "<trace source=${source} lineno=${lineno} funcname=${funcname}/>"
|
||||||
>>"$MIAOU_BASH_ERROR_CHILDREN" echo -e "\tmiaou_trace: source=${source} lineno=${lineno} funcname=${funcname}"
|
>>"$MIAOU_BASH_ERROR_CHILDREN" echo -e "\tmiaou_trace: source=${source} lineno=${lineno} funcname=${funcname}"
|
||||||
done
|
done
|
||||||
|
for i in "${tmp_error[@]}"; do >>"$MIAOU_BASH_ERROR_CHILDREN" echo "$i"; done
|
||||||
miaou_debug "</save_stacktrace_to_stderr>"
|
miaou_debug "</save_stacktrace_to_stderr>"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,7 +323,25 @@ function dump_stacktrace {
|
|||||||
function load_tmp_error {
|
function load_tmp_error {
|
||||||
miaou_debug "<load_tmp_error from=$MIAOU_BASH_ERROR>"
|
miaou_debug "<load_tmp_error from=$MIAOU_BASH_ERROR>"
|
||||||
if [[ ! -v tmp_error ]]; then
|
if [[ ! -v tmp_error ]]; then
|
||||||
|
local count count_children tmp_error_children
|
||||||
|
if [[ -f "$MIAOU_BASH_ERROR_CURRENT_CHILDREN" ]]; then
|
||||||
|
miaou_debug "<tmp_children found=$MIAOU_BASH_ERROR_CURRENT_CHILDREN>"
|
||||||
|
mapfile -t tmp_error_children <"$MIAOU_BASH_ERROR_CURRENT_CHILDREN"
|
||||||
|
local count_children=${#tmp_error_children[@]}
|
||||||
|
if [[ $count_children == 0 ]]; then
|
||||||
|
miaou_debug "<tmp_error_children empty/>"
|
||||||
|
else
|
||||||
|
miaou_debug "<tmp_error_children count=${count_children}>"
|
||||||
|
fi
|
||||||
|
miaou_debug "</tmp_children>"
|
||||||
|
rm "$MIAOU_BASH_ERROR_CURRENT_CHILDREN"
|
||||||
|
fi
|
||||||
|
|
||||||
mapfile -t tmp_error <"$MIAOU_BASH_ERROR"
|
mapfile -t tmp_error <"$MIAOU_BASH_ERROR"
|
||||||
|
|
||||||
|
if [[ -v count_children && $count_children -gt 0 ]]; then
|
||||||
|
tmp_error=("${tmp_error[@]}" "${tmp_error_children[@]}")
|
||||||
|
fi
|
||||||
local count=${#tmp_error[@]}
|
local count=${#tmp_error[@]}
|
||||||
if [[ $count == 0 ]]; then
|
if [[ $count == 0 ]]; then
|
||||||
miaou_debug "<tmp_error empty/>"
|
miaou_debug "<tmp_error empty/>"
|
||||||
@@ -448,21 +466,18 @@ function build_miaou_bash_error {
|
|||||||
[[ -f "${directory}/${PPID}.tmp" ]] && CHILD_PROCESS=true
|
[[ -f "${directory}/${PPID}.tmp" ]] && CHILD_PROCESS=true
|
||||||
|
|
||||||
mkdir -p "$directory"
|
mkdir -p "$directory"
|
||||||
if is_true $CHILD_PROCESS; then
|
MIAOU_BASH_ERROR_CURRENT_CHILDREN="${directory}/$$.children.tmp"
|
||||||
MIAOU_BASH_ERROR_CHILDREN="${directory}/${PPID}.children.tmp"
|
MIAOU_BASH_ERROR_CHILDREN="${directory}/${PPID}.children.tmp"
|
||||||
fi
|
|
||||||
MIAOU_BASH_ERROR="${directory}/$$.tmp"
|
MIAOU_BASH_ERROR="${directory}/$$.tmp"
|
||||||
rm -f "$MIAOU_BASH_ERROR"
|
rm -f "$MIAOU_BASH_ERROR"
|
||||||
|
|
||||||
readonly MIAOU_BASH_ERROR_CHILDREN MIAOU_BASH_ERROR CHILD_PROCESS
|
readonly MIAOU_BASH_ERROR_CURRENT_CHILDREN MIAOU_BASH_ERROR_CHILDREN MIAOU_BASH_ERROR CHILD_PROCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup {
|
function cleanup {
|
||||||
if ! is_true $CHILD_PROCESS; then
|
miaou_debug '<cleanup />'
|
||||||
miaou_debug '<cleanup main/>'
|
trap - ERR EXIT PIPE RETURN
|
||||||
trap - ERR EXIT PIPE RETURN
|
rm -f "$MIAOU_BASH_ERROR"
|
||||||
# rm "$MIAOU_BASH_ERROR"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## main
|
## main
|
||||||
|
|||||||
Reference in New Issue
Block a user