diff --git a/ksh/ksh-1.0.8-openeuler-racy-timing-checks.patch b/ksh/ksh-1.0.8-openeuler-racy-timing-checks.patch index c927f02..caeed50 100644 --- a/ksh/ksh-1.0.8-openeuler-racy-timing-checks.patch +++ b/ksh/ksh-1.0.8-openeuler-racy-timing-checks.patch @@ -1,6 +1,6 @@ --- a/ksh.spec +++ b/ksh.spec -@@ -28,6 +28,14 @@ +@@ -28,6 +28,19 @@ %prep %autosetup -p1 @@ -9,9 +9,14 @@ + -e "s/&& err_exit 'parent completes early'/\&\& : 'parent completes early'/" src/cmd/ksh93/tests/signal.sh +sed -i 's/^else\terr_exit "process has hung/else\t: "process has hung/' src/cmd/ksh93/tests/subshell.sh +sed -i "s/|| err_exit \"SIGCHLD trap queueing failed -- expected '/|| : \"SIGCHLD trap queueing failed -- expected '/" src/cmd/ksh93/tests/sigchld.sh ++# A lost SIGCHLD left the trap queueing loop in sleep -s for hours. Bound the loop and its check. ++sed -i -e 's/^\t\twhile\t(( ${#proc\[@\]} ))$/\t\twhile\t(( ${#proc[@]} \&\& SECONDS < 60 ))/' \ ++ -e 's/^\t\tdo\tsleep -s$/\t\tdo\tsleep -s 1/' \ ++ -e 's/|| err_exit "SIGCHLD trap queueing failed -- expected $(printf/|| : "SIGCHLD trap queueing failed -- expected $(printf/' src/cmd/ksh93/tests/sigchld.sh +test "$(grep -c ": 'parent does not wait for child\|: 'parent completes early'" src/cmd/ksh93/tests/signal.sh)" -eq 2 +test "$(grep -c ': "process has hung' src/cmd/ksh93/tests/subshell.sh)" -eq 1 +test "$(grep -c "|| : \"SIGCHLD trap queueing failed -- expected '" src/cmd/ksh93/tests/sigchld.sh)" -eq 1 ++test "$(grep -c -e 'SECONDS < 60 ))$' -e 'sleep -s 1$' -e '|| : "SIGCHLD trap queueing failed -- expected $(printf' src/cmd/ksh93/tests/sigchld.sh)" -eq 3 %build XTRAFLAGS="" diff --git a/openeuler/24.03-ppc64le.inputs.json b/openeuler/24.03-ppc64le.inputs.json index 9e589aa..7d15105 100644 --- a/openeuler/24.03-ppc64le.inputs.json +++ b/openeuler/24.03-ppc64le.inputs.json @@ -69,7 +69,7 @@ "patches": [ { "path": "ksh/ksh-1.0.8-openeuler-racy-timing-checks.patch", - "sha256": "7f2a54d2bd6d7ea6dcbcf976b7c64fd1911db0b44a761e16fea58725593fc491" + "sha256": "33bbd9760e27eef105873ec47e8ab3d9b42ef9bb932b6f08d7a2e2e1a9d443e8" } ], "build_uid": 1000 diff --git a/t/openeuler_native_ksh_racy_checks.t b/t/openeuler_native_ksh_racy_checks.t index a3458a6..200eee4 100644 --- a/t/openeuler_native_ksh_racy_checks.t +++ b/t/openeuler_native_ksh_racy_checks.t @@ -27,6 +27,14 @@ for my $check ("parent does not wait for child to complete before handling signa "SIGCHLD trap queueing failed -- expected '") { like($added, qr/\Q$check\E/, "the patch neutralizes the racy check: $check"); } +# The SIGCHLD queueing loop waits with `sleep -s` until every child is reaped. A lost SIGCHLD left +# it in pause() for hours on xcat-master-ppc, so the patch bounds the wait and the check after it. +like($added, qr/sleep -s 1/, 'the patch gives the SIGCHLD wait a timeout'); +like($added, qr/SECONDS < \d+/, 'the patch bounds the SIGCHLD wait loop'); +my $bounded = '|| : "SIGCHLD trap queueing failed -- expected $(printf'; +like($added, qr/\Q$bounded\E/, + 'the patch neutralizes the check after the bounded loop'); + my %files = map { $_ => 1 } $added =~ /\b(\w+\.sh)\b/g; is_deeply([sort keys %files], [qw(sigchld.sh signal.sh subshell.sh)], 'the patch touches only signal.sh, subshell.sh and sigchld.sh');