From 0d560466c79dbdb62e264637894ca6dd2dff1beb Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Fri, 18 Mar 2016 19:34:21 +0900 Subject: [PATCH] Fix signal handing --- test.sh | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/test.sh b/test.sh index e809de6..da4607b 100755 --- a/test.sh +++ b/test.sh @@ -6,6 +6,14 @@ function INFO(){ echo -e "\e[104m\e[97m[INFO]\e[49m\e[39m $@" } +function dokillkill () { + sleep 5; + kill -9 ${1} + return ${?} +} + +_e=0 + INFO 'Checking whether hitting docker#18180.' for f in $(seq 1 100);do taskset 0x1 java 2> /dev/null || true; @@ -17,10 +25,27 @@ INFO 'OK. not hitting docker#18180.' INFO 'Checking whether sendfile(2) is killable.' INFO 'If the container hangs up here, you are still facing the bug that linux@296291cd tried to fix.' /sendfile-test & -sleep 5 -kill -9 $! -wait $! -INFO 'OK. sendfile(2) is killable.' - -INFO 'PERFECT!' - +_e=${?}; +if [ ${_e} -ne 0 ]; then + INFO "Error(${?}) failed to run /sendfile-test in background" + exit ${_e} +else + _bpid="${!}" + _dvs="$( date )" + dokillkill "${_bpid}" & + _e=${?}; + if [ ${_e} -ne 0 ]; then + INFO "Error(${?}) failed to run DOKILLKILL ${_bpid} in background" + kill -9 ${_bpid} + exit ${_e}; + else + _kpid=${!} + if wait ${_bpid}; then + _e=${?} + else + _e=${?} + fi + _dve="$( date )" + INFO "OK. sendfile(2) is killable when ( ${_dve} - ${_dvs} => 5s ) and exit code ${_e} != 0." + fi +fi