From: Alan T. DeKok Date: Sun, 19 Sep 2010 06:41:44 +0000 (+0200) Subject: Various fixes X-Git-Tag: release_3_0_0_beta0~1237 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=freeradius.git;a=commitdiff_plain;h=445aadf8ff234344d19817eef5f6d10bb0ba6bb0 Various fixes If timeout is zero, set it to 1^6. That should be good enough. Don't filter output through sed, this makes it impossible to kill the "tail" process. Catch the tail PID, and kill it on exit. Trap on signals, not on normal exit. Duplicate code in trap for normal exit. This ensures that the code is only executed once. --- diff --git a/scripts/raddebug b/scripts/raddebug index 3fac9de..a799ba8 100755 --- a/scripts/raddebug +++ b/scripts/raddebug @@ -52,6 +52,7 @@ do extra="-f $OPTARG" ;; t) timeout="$OPTARG" + [ "$timout" = "0" ] && timeout=1000000 ;; u) condition="(User-Name == $OPTARG)" ;; @@ -94,10 +95,12 @@ fi cp /dev/null $outfile chmod g+w $outfile +TAILPID=$$ + # # Set the trap to clean up on exit and any interrupts. # -trap '$radmin -e "debug condition" -e "debug file"; rm -f $outfile; exit 0' 0 1 2 15 +trap '$radmin -e "debug condition" -e "debug file"; rm -f $outfile;kill -TERM $TAILPID;exit 0' 1 2 15 # # Set the debug condition @@ -107,6 +110,9 @@ $radmin -e "debug condition \"$condition\"" # # Print the output, and wait for "timeout". Then, stop printing. # -(tail -f $outfile | sed 's/^.*Debug: //') & +tail -f $outfile & +TAILPID=$! sleep $timeout -kill -INT %1 +kill -TERM $TAILPID +$radmin -e "debug condition" -e "debug file" +rm -f $outfile