diff --git a/async.zsh b/async.zsh index 2b6ed01..7f61ce2 100644 --- a/async.zsh +++ b/async.zsh @@ -117,6 +117,10 @@ _async_worker() { # pids of child processes. unsetopt monitor + # Worker name, for debugging purposes. + local worker_name=$1 + shift + # Redirect stderr to `/dev/null` in case unforseen errors produced by the # worker. For example: `fork failed: resource temporarily unavailable`. # Some older versions of zsh might also print malloc errors (know to happen @@ -124,6 +128,7 @@ _async_worker() { if ((ASYNC_DEBUG)); then exec 2>>${ASYNC_DEBUG_WORKER_STDERR} if [[ $ASYNC_DEBUG_WORKER_STDERR != /dev/null ]]; then + PROMPT4="(async):${worker_name}> ${PROMPT4}" setopt xtrace fi else @@ -635,9 +640,9 @@ async_start_worker() { } if (( errfd != -1 )); then - zpty -b $worker _async_worker -p $$ $args 2>&$errfd + zpty -b $worker _async_worker $worker -p $$ $args 2>&$errfd else - zpty -b $worker _async_worker -p $$ $args + zpty -b $worker _async_worker $worker -p $$ $args fi local ret=$? diff --git a/async_test.zsh b/async_test.zsh index 6b58919..8b813fa 100644 --- a/async_test.zsh +++ b/async_test.zsh @@ -651,6 +651,14 @@ test_zle_watcher() { test_main() { # Load zsh-async before running each test. zmodload zsh/datetime + if [[ -o xtrace ]]; then + typeset -g ASYNC_DEBUG ASYNC_DEBUG_WORKER_STDERR + export ASYNC_DEBUG=1 + # Output to special fd from test runner. + # TODO(mafredri): + exec 9> >(cat) + export ASYNC_DEBUG_WORKER_STDERR=/dev/fd/9 + fi . ./async.zsh async_init } diff --git a/test.zsh b/test.zsh index 01ded81..a26c588 100755 --- a/test.zsh +++ b/test.zsh @@ -15,13 +15,13 @@ zmodload zsh/zselect TEST_GLOB=. TEST_RUN= TEST_VERBOSE=0 -TEST_TRACE=1 +TEST_TRACE=0 TEST_CODE_SKIP=100 TEST_CODE_ERROR=101 TEST_CODE_TIMEOUT=102 show_help() { - print "usage: ./test.zsh [-v] [-x] [-run pattern] [search pattern]" + print "usage: ./test.zsh [-h] [-v] [-x] [-d] [-run pattern] [search pattern]" } parse_opts() {