generic/504: fix hard coded fd number
authorMurphy Zhou <xzhou@redhat.com>
Mon, 8 Apr 2019 02:38:59 +0000 (10:38 +0800)
committerEryu Guan <guaneryu@gmail.com>
Sun, 14 Apr 2019 11:05:36 +0000 (19:05 +0800)
Bash supports file discriptor assignment in this way. So remove the hard
coded numbers. Also close this opened fd in cleanup.

Signed-off-by: Murphy Zhou <xzhou@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/generic/504

index 21d8605136c0170abf44dc6064ff6507bc8e2540..19c6a0e75cf062b6c02bc29195df1cca7eabd369 100755 (executable)
@@ -21,6 +21,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
+       exec {test_fd}<&-
        cd /
        rm -f $tmp.*
 }
@@ -45,9 +46,9 @@ tf_inode=$(stat -c %i $testfile)
 echo inode $tf_inode >> $seqres.full
 
 # Create new fd by exec
-exec 9> $testfile
+exec {test_fd}> $testfile
 # flock locks the fd then exits, we should see the lock info even the owner is dead
-flock -x 9
+flock -x $test_fd
 cat /proc/locks >> $seqres.full
 
 # Checking