X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2Fresources%2Fscripts%2Foperation_signal.sh;h=da0449b91f7cb72ba79ce6611c79f31b3009e723;hb=fbe71916b6bcafa22a9f47f0bc2a2e30ee5a8d88;hp=3c928cef6b4a97f65e19feae34bb8790bb72c187;hpb=e7bae4d2a11f043f8dcabcb14222a48d3bc37b99;p=anna.git diff --git a/example/diameter/launcher/resources/scripts/operation_signal.sh b/example/diameter/launcher/resources/scripts/operation_signal.sh index 3c928ce..da0449b 100755 --- a/example/diameter/launcher/resources/scripts/operation_signal.sh +++ b/example/diameter/launcher/resources/scripts/operation_signal.sh @@ -20,7 +20,7 @@ usage() { echo echo " -h|--help: this usage help." echo " -t|--timeout: timeout for operation in seconds." - echo " Defaults to 2 seconds if not provided." + echo " Defaults to $TIMEOUT__dflt seconds if not provided." echo echo " -f|--file: the parameter 'data' will be interpreted as a file" echo " with one operation per line. If missing, it will be" @@ -94,35 +94,35 @@ parse_arguments $@ # Send operation: if [ -n "$is_file" ] then - grep -v "^#" $data | sed '/^[ \t]*$/d' > sigusr2.in + cp $data sigusr2.in else echo $data > sigusr2.in fi -0> sigusr2.out +0>sigusr2.out check_pid $PID kill -s SIGUSR2 $PID # Detect EOF and print all except that last line: -sleep $timeout & -timerPid=$! -rm -f .operation_eof -tail -n0 -F --pid=$timerPid sigusr2.out | while read line -do - if echo $line | grep "^EOF" >/dev/null; then - touch .operation_eof - # stop the timer - kill -13 $timerPid +count=$((10*timeout)) +expired=yes +while [ $count -gt 0 ] +do + sleep 0.1 + count=$((count-1)) + if tail -1 sigusr2.out | grep "^EOF" >/dev/null; then + expired= + break; fi -done +done -if [ -f .operation_eof ] +if [ -z "$expired" ] then head --lines=-1 sigusr2.out else _exit "Operation error: timeout expired ($timeout seconds)" fi -exception=$(grep exception sigusr2.out) -[ $? -eq 0 -a "$data" != "help" ] && _exit "(detected 'exception' within operation output)" +exception=$(grep "^Operation processed with exception: " sigusr2.out) +[ $? -eq 0 ] && _exit "(detected 'exception' within operation output: see 'launcher.trace')" exit 0