test-lib: translate SIGTERM and SIGHUP to an exit

Right now if a test script receives SIGTERM or SIGHUP (e.g., because a test was hanging and the user 'kill'-ed it or simply closed the terminal window the test was running in), the shell exits immediately. This can be annoying if the test script did any global setup, like starting apache or git-daemon, as it will not have an opportunity to clean up after itself. A subsequent run of the test won't be able to start its own daemon, and will either fail or skip the tests. Instead, let's trap SIGTERM and SIGHUP as well to make sure we do a clean shutdown, and just chain it to a normal exit (which will trigger any cleanup). This patch follows suit of da706545f7 (t: translate SIGINT to an exit, 2015-03-13), and even stole its commit message as well. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Dec 30, 2018 at 20:16 UTC d45cec4bea4250e7aabb1415ae4d50e0eccaa4b7
1 file changed +1 -1
t/test-lib.sh
+1 -1
@@ -476,7 +476,7 @@ die () {
476
477 GIT_EXIT_OK=
478 trap 'die' EXIT
479 -trap 'exit $?' INT
479 +trap 'exit $?' INT TERM HUP
480
481 # The user-facing functions are loaded from a separate file so that
482 # test_perf subshells can have them too