[PATCH 2/2] merge_config.sh: trap signals and clean up

From: Darren Hart
Date: Mon Sep 26 2011 - 23:26:00 EST


The script creates a temp file, but doesn't ensure that it cleans up after
itself in the event of a signal.

Trap SIGHUP SIGINT and SIGTERM and remove the temp file.

Signed-off-by: Darren Hart <dvhart@xxxxxxxxxxxxxxx>
---
scripts/kconfig/merge_config.sh | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh
index a644724..a4b1bad 100755
--- a/scripts/kconfig/merge_config.sh
+++ b/scripts/kconfig/merge_config.sh
@@ -20,11 +20,15 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.

-MERGE_LIST=$*
+clean_up() {
+ rm -f $TMP_FILE
+ exit
+}

+trap clean_up SIGHUP SIGINT SIGTERM

+MERGE_LIST=$*
TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX)
-
SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p"

# Merge files, printing warnings on overrided values
@@ -65,5 +69,4 @@ for CFG in `sed -n "$SED_CONFIG_EXP" $TMP_FILE`; do
fi
done

-# Cleanup
-rm $TMP_FILE
+clean_up
--
1.7.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/