| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='signals work as we expect' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | cat >expect <<EOF |
| 8 | three |
| 9 | two |
| 10 | one |
| 11 | EOF |
| 12 | |
| 13 | test_expect_success 'sigchain works' ' |
| 14 | { test-tool sigchain >actual; ret=$?; } && |
| 15 | { |
| 16 | # Signal death by raise() on Windows acts like exit(3), |
| 17 | # regardless of the signal number. So we must allow that |
| 18 | # as well as the normal signal check. |
| 19 | test_match_signal 15 "$ret" || |
| 20 | test "$ret" = 3 |
| 21 | } && |
| 22 | test_cmp expect actual |
| 23 | ' |
| 24 | |
| 25 | test_expect_success !MINGW 'signals are propagated using shell convention' ' |
| 26 | # we use exec here to avoid any sub-shell interpretation |
| 27 | # of the exit code |
| 28 | git config alias.sigterm "!exec test-tool sigchain" && |
| 29 | test_expect_code 143 git sigterm |
| 30 | ' |
| 31 | |
| 32 | large_git () { |
| 33 | for i in $(test_seq 1 100) |
| 34 | do |
| 35 | git diff --cached --binary || return |
| 36 | done |
| 37 | } |
| 38 | |
| 39 | test_expect_success 'create blob' ' |
| 40 | test-tool genrandom foo 16384 >file && |
| 41 | git add file |
| 42 | ' |
| 43 | |
| 44 | test_expect_success !MINGW 'a constipated git dies with SIGPIPE' ' |
| 45 | OUT=$( ((large_git && echo 0 1>&3 || echo $? 1>&3) | :) 3>&1 ) && |
| 46 | test_match_signal 13 "$OUT" |
| 47 | ' |
| 48 | |
| 49 | test_expect_success !MINGW 'a constipated git dies with SIGPIPE even if parent ignores it' ' |
| 50 | OUT=$( ((trap "" PIPE && large_git && echo 0 1>&3 || echo $? 1>&3) | :) 3>&1 ) && |
| 51 | test_match_signal 13 "$OUT" |
| 52 | ' |
| 53 | |
| 54 | test_done |