Andrew Black wrote:
Greetings all
At this time, if the run_locale_utils.sh script is killed as the result
of a signal, the temporary directory that was created is not cleaned up.
I believe that this behavior is generally considered impolite. The
attached patch and following change log aim to fix this oversight.
Looks good to me. Committed as follows:
http://svn.apache.org/viewvc?rev=432763&view=rev
Thanks
Martin
--Andrew Black
Log:
* run_locale_utils.sh (test_locale): Remove redundant calls to rm.
(signal_cleanup): Add exit handler for cleaning up tempdir.
(main): set EXIT trap before calling test_locale, remove redundant
rm call.
------------------------------------------------------------------------
Index: etc/config/run_locale_utils.sh
===================================================================
--- etc/config/run_locale_utils.sh (revision 432251)
+++ etc/config/run_locale_utils.sh (working copy)
@@ -293,17 +293,16 @@
echo "ERROR: $2/out.2 $2/out.3 differ." > $dbgout
failedassertions=`expr $failedassertions + 1`
fi
+}
- # and remove database
- [ -d $2/$3 ] && rm -rf $2/$3
+#
+# Cleanup handler
+#
- # remove dump files
- [ -f $2/out.1 ] && rm $2/out.1
- [ -f $2/out.2 ] && rm $2/out.2
- [ -f $2/out.3 ] && rm $2/out.3
-
- # and finally remove the tmp directory
- [ -d $2 ] && rm -rf $2
+signal_cleanup()
+{
+ echo "Cleaning up" $tmpdir > $dbgout
+ rm -rf $tmpdir
}
##############################################################################
@@ -328,6 +327,10 @@
out="/dev/stdout"
dbgout="/dev/null"
+## Temporary (working) directory
+[ -z "$TMP" ] && TMP="/tmp";
+tmpdir=$TMP/locale.$$
+
## Get the options from the command line
while getopts ":sfdb:i:l:O:L:M:C:D:" opt_name; do
case $opt_name in
@@ -359,9 +362,7 @@
elif [ "$chk_func" = "yes" ]; then
- ## set the temp dir
- [ -z "$TMP" ] && TMP="/tmp";
- tmpdir=$TMP/locale.$$
+ ## create the temp dir
mkdir $tmpdir
if [ $? -ne 0 ]; then
echo "$0: Unable to create $tmpdir, aborting" >&2
@@ -378,10 +379,11 @@
echo "export RWSTD_LOCALE_ROOT" >$dbgout
export RWSTD_LOCALE_ROOT
+ # Set our cleanup on exit trap
+ trap signal_cleanup EXIT
+
# test only one locale
test_locale $nlsdir $tmpdir $locale_db;
-
- rm -rf $tmpdir
else
## Invocation is wrong
echo "$0: Usage : " >&2