Fix leaked file descriptors
authorMichael Lass <lass@mail.uni-paderborn.de>
Fri, 20 Sep 2013 13:41:09 +0000 (15:41 +0200)
committerMichael Lass <lass@mail.uni-paderborn.de>
Fri, 20 Sep 2013 13:41:09 +0000 (15:41 +0200)
When running prepare_grub_to_access_device inside of the here document a file
descriptor to a temporary file is leaked. When prepare_grub_to_access_device
calls various lvm related commands these will complain about this.

Minimum example:
<< EOF
"$(lvs)"
EOF

Avoid this by calling prepare_grub_to_access_device before assembling the
output.

42_grml

diff --git a/42_grml b/42_grml
index 8fce10c..30f1c07 100755 (executable)
--- a/42_grml
+++ b/42_grml
@@ -100,10 +100,11 @@ for grmliso in $iso_list ; do
 
   echo "Found Grml ISO image: $grmliso" >&2
   title="Grml Rescue System ($grml)"
+  grub_prep=$(prepare_grub_to_access_device "$device" | sed -e "s/^/        /")
 
   cat << EOF
 menuentry "${title}" {
-$(prepare_grub_to_access_device "$device" | sed -e "s/^/        /")
+${grub_prep}
         iso_path="${rel_dirname}/${grml}"
         export iso_path
         kernelopts=" $CUSTOM_BOOTOPTIONS $additional_param "