Test driver doesn't always kill child processes
If I run a (compiler performance) test that causes GHC to run for a long time, then interrupt the test with Ctrl-C, the background process being tested is not always interrupted. This can be particularly problematic if the branch I'm testing has a bug that causes GHC to loop consuming 100% CPU, because I have to manually kill the background process.
Steps to reproduce
I noticed this with the test introduced in 3945b22f and a locally-modified GHC checkout. Presumably this should be reproducible with other tests though. My specific Hadrian invocation was:
hadrian/build -j --skip-depends --docs=none --flavour=perf -o_build_perf2 --freeze1 test --test-root-dirs=testsuite/tests/perf --only=T15703
I waited until the test started running, then hit Ctrl-C. This produced the following test output:
=====> 1 of 1 [0, 0, 0] ^C Performance Metrics (test environment: local): None collected. SUMMARY for test run started at Fri Apr 9 10:31:54 2021 0:00:00.792117 spent to go through 1 total tests, which gave rise to 4 test cases, of which 0 were skipped 0 had missing libraries 0 expected passes 0 expected failures 0 caused framework failures 0 caused framework warnings 0 unexpected passes 0 unexpected failures 0 unexpected stat failures 0 fragile tests user interrupt
In the background, the following processes were still running:
/bin/sh -c cd "/tmp/ghctest-anvmbliz/test spaces/testsuite/tests/perf/compiler/T15703.run" && ".../ghc/_build_perf2/stage1/bin/ghc" --make T15703 -no-user-package-db -rtsopts -fno-warn-missed-specialisations -fshow-warning-groups -fdiagnostics-color=never -fno-diagnostics-show-caret -Werror=compat -dno-debug-output -v0 -O +RTS -V0 -tT15703.comp.stats --machine-readable -RTS .../ghc/_build_perf2/stage1/bin/ghc --make T15703 -no-user-package-db -rtsopts -fno-warn-missed-specialisations -fshow-warning-groups -fdiagnostics-color=never -fno-diagnostics-show-caret -Werror=compat -dno-debug-output -v0 -O +RTS -V0 -tT15703.comp.stats --machine-readable -RTS
When I hit Ctrl-C to interrupt a test, all processes associated with that test should be killed.
- GHC version used: GHC HEAD (actually a branch off 3945b22f heavily modified locally) bootstrapped with 9.0.1
- Operating System: Linux
- System Architecture: x86_64