Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Jan 2009 15:04:54 -0800
From:      Nerius Landys <nlandys@gmail.com>
To:        Maxim Khitrov <mkhitrov@gmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: shell scripting, how to auto-timeout?
Message-ID:  <560f92640901231504w5d218736p64241bbda7e9b65f@mail.gmail.com>
In-Reply-To: <560f92640901231058i3c9e8645n6a30c74ec868ba87@mail.gmail.com>
References:  <560f92640901221241y4fc1620aree083a812c1f3c8d@mail.gmail.com> <26ddd1750901221333x5356f4f3l6b6410fc05d4e6d4@mail.gmail.com> <560f92640901221451j2e2b259bw1559a8c8d8912941@mail.gmail.com> <560f92640901221458y9409360n34904461fb2580e4@mail.gmail.com> <26ddd1750901221635k17230c7eudb1edc38c808eb83@mail.gmail.com> <560f92640901231058i3c9e8645n6a30c74ec868ba87@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
I decided that I want the exec line at the end of the script because I
want the exit code of the script to be the exit code of the Java
process.  I'm willing to live with the fact that the sleep thread will
wait its full 3 seconds. So my final script is this:

#!/bin/sh

cd `dirname "$0"`
CLASSPATH="mapgen.jar"
export CLASSPATH

THIS_SCRIPT_PROCESS="$$"
sleep 3 && kill "$THIS_SCRIPT_PROCESS" > /dev/null 2>&1 && \
  echo "Terminated infinite looping." 1>&2 &
#SLEEP_PROCESS="$!"

exec /usr/local/bin/java $*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?560f92640901231504w5d218736p64241bbda7e9b65f>