From db8d3910efdaf735fa51f012fb48b52e23f25c4c Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 26 Apr 2010 16:33:52 +0200 Subject: Reap child processes on EXIT --- noise | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/noise b/noise index 481f2c09..fe67052c 100755 --- a/noise +++ b/noise @@ -6,7 +6,7 @@ noise_set() { # set a variable s/^noise_([[:alnum:]_]+)=(.*)$/\1 = \2/p ' | sort elif test "x$2" = x ; then - eval "echo \"$1 is \$noise_$1\"" + eval "echo \"$1 = \$noise_$1\"" else if echo "$1" | grep -q '[^[:alnum:]_]' ; then fail invalid variable name "$1" @@ -35,8 +35,13 @@ fail() { return 23 } +cleanup() { + rm -f $linefeed + kill $jobs +} + linefeed="/tmp/noise-client-$$" -trap "rm -f $linefeed" EXIT +trap cleanup EXIT mkfifo $linefeed while eval `{ read && echo $REPLY ; } | tr -d \' | sed -rn " s:^/([a-z]+)([[:space:]]+(.*))?$:command='\1'; args='\3';:p;t @@ -60,6 +65,7 @@ while eval `{ read && echo $REPLY ; } | tr -d \' | sed -rn " ## fail unknown command "$command" done <$linefeed & +jobs="${jobs+$jobs }`jobs -p`" cat</dev/null ; then - noise_"$@" - : && return - fi - return 23 -} -- cgit v1.2.3