Hi!
> +# tst_timeout "command arg1 arg2 ..." timeout
> +# Runs command for specified timeout (in seconds).
> +# Function returns retcode of command or 1 if arguments are invalid.
> +tst_timeout()
> +{
> + local command=$1
> + local timeout=$(echo $2 | grep -o "^[0-9]\+$")
> +
> + # command must be non-empty string with command to run
> + if [ -z "$command" ]; then
> + echo "first argument must be non-empty string"
> + return 1
> + fi
> +
> + # accept only numbers as timeout
> + if [ -z "$timeout" ]; then
> + echo "only numbers as second argument"
> + return 1
> + fi
> +
> + setsid sh -c "eval $command" 2>&1 &
> + local pid=$!
> + local pgid=$(ps -eo pid,pgid | grep $pid | sed 's/^.* //')
Hmm, wouldn't be the $pid == $pgid in this case? Or is there a scenario
where this would not hold?
Otherwise it looks good to me.
--
Cyril Hrubis
[email protected]
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list