1#!/bin/sh
23
test_description='signals work as we expect'
4. ./test-lib.sh
56
cat >expect <<EOF
7three
8two
9one
10EOF
1112
test_expect_success 'sigchain works' '
13{ test-sigchain >actual; ret=$?; } &&
14case "$ret" in
15143) true ;; # POSIX w/ SIGTERM=15
16271) true ;; # ksh w/ SIGTERM=15
173) true ;; # Windows
18*) false ;;
19esac &&
20test_cmp expect actual
21'
2223
test_expect_success !MINGW 'signals are propagated using shell convention' '
24# we use exec here to avoid any sub-shell interpretation
25# of the exit code
26git config alias.sigterm "!exec test-sigchain" &&
27test_expect_code 143 git sigterm
28'
2930
large_git () {
31for i in $(test_seq 1 100)
32do
33git diff --cached --binary || return
34done
35}
3637
test_expect_success 'create blob' '
38test-genrandom foo 16384 >file &&
39git add file
40'
4142
test_expect_success !MINGW 'a constipated git dies with SIGPIPE' '
43OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&
44test "$OUT" -eq 141
45'
4647
test_expect_success !MINGW 'a constipated git dies with SIGPIPE even if parent ignores it' '
48OUT=$( ((trap "" PIPE; large_git; echo $? 1>&3) | :) 3>&1 ) &&
49test "$OUT" -eq 141
50'
5152
test_done