git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 01/11] test-lib: fix interrupt handling with 'dash' and '--verbose-log -x'

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 14, 2019, 02:18 UTC
Message-ID
<xmqq1s3aci66.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20190313122419.2210-2-szeder.dev@gmail.com>
SZEDER Gábor <szeder.dev@gmail.com> writes:
Show 7 quoted lines
> Putting these together, when a test script run with 'dash' and
> '--verbose-log -x' is interrupted, then 'dash' tries to write the
> trace output from the EXIT trap to the script's original standard
> error, but it very likely can't, because the 'tee' downstream of the
> pipe is interrupted as well.  This causes the shell running the test
> script to die because of SIGPIPE, without running any of the commands
> in the EXIT trap.

So... the clean-up actions do not get a chance to run because the shell that is going to execute would be killed by SIGPIPE because tee that is reading from it goes away?

While I like the patch very much, I also wonder if it is possible to tell tee to not to die upon seeing INT, TERM, etc. When the shell upstream of tee exits (after performing clean-up actions), tee that is reading from it will exit, too, and will not be left behind (I do not mean to say it that is a better alternative solution---I am just trying to see if I read the problem correctly from the description given above).

Show 16 quoted lines
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 8665b0a9b6..db3875d1e4 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -631,7 +631,10 @@ die () {
>  
>  GIT_EXIT_OK=
>  trap 'die' EXIT
> -trap 'exit $?' INT TERM HUP
> +# Disable '-x' tracing, because with some shells, notably dash, it
> +# prevents running the cleanup commands when a test script run with
> +# '--verbose-log -x' is interrupted.
> +trap '{ code=$?; set +x; } 2>/dev/null; exit $code' INT TERM HUP
>  
>  # The user-facing functions are loaded from a separate file so that
>  # test_perf subshells can have them too
Thanks.
Previous: SZEDER GáborNext: SZEDER Gábor
Message 3 of 21 in “tests: introduce 'test_atexit'”
  1. 00/11 tests: introduce 'test_atexit'SZEDER Gábor, Mar 13, 2019
  2. 01/11 test-lib: fix interrupt handling with 'dash' and '--verbose-log -x'SZEDER Gábor, Mar 13, 2019
  3. Junio C HamanoMar 14, 2019
  4. SZEDER GáborMar 14, 2019
  5. 02/11 t/lib-git-daemon: make sure to kill the 'git-daemon' processSZEDER Gábor, Mar 13, 2019
  6. Junio C HamanoMar 14, 2019
  7. 04/11 git-daemon: use 'test_atexit` to stop 'git-daemon'SZEDER Gábor, Mar 13, 2019
  8. 03/11 test-lib: introduce 'test_atexit'SZEDER Gábor, Mar 13, 2019
  9. Junio C HamanoMar 14, 2019
  10. SZEDER GáborMar 14, 2019
  11. Junio C HamanoMar 18, 2019
  12. 05/11 tests: use 'test_atexit' to stop httpdSZEDER Gábor, Mar 13, 2019
  13. Junio C HamanoMar 14, 2019
  14. Junio C HamanoMar 14, 2019
  15. SZEDER GáborMar 14, 2019
  16. 06/11 t0301-credential-cache: use 'test_atexit' to stop the credentials helperSZEDER Gábor, Mar 13, 2019
  17. 07/11 git p4 test: use 'test_atexit' to kill p4d and the watchdog processSZEDER Gábor, Mar 13, 2019
  18. 10/11 git p4 test: disable '-x' tracing in the p4d watchdog loopSZEDER Gábor, Mar 13, 2019
  19. 09/11 git p4 test: simplify timeout handlingSZEDER Gábor, Mar 13, 2019
  20. 11/11 t9811-git-p4-label-import: fix pipeline negationSZEDER Gábor, Mar 13, 2019
  21. 08/11 git p4 test: clean up the p4d cleanup functionsSZEDER Gábor, Mar 13, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.