[kexec-tools] kdumpctl: display message while waiting for the single instance lock

WANG Chao wangchao at fedoraproject.org
Fri Jul 18 05:31:51 UTC 2014


commit 463742ad9547c1a8dacc1df091cc8a6f9f243727
Author: WANG Chao <chaowang at redhat.com>
Date:   Wed Jul 16 20:09:48 2014 +0800

    kdumpctl: display message while waiting for the single instance lock
    
    Vivek suggested we should display message while waiting for the lock,
    because the waiting could be long and user will have no idea what's
    going on.
    
    So we will repeat the following message every 5 seconds while waiting:
    
    "Another app is currently holding the kdump lock; waiting for it to exit..."
    
    Thanks Vivek for providing a more comprehensive message.
    
    Signed-off-by: WANG Chao <chaowang at redhat.com>
    Acked-by: Vivek Goyal <vgoyal at redhat.com>

 kdumpctl |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/kdumpctl b/kdumpctl
index 9cae0c4..0025620 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -20,8 +20,18 @@ fi
 
 single_instance_lock()
 {
+	local rc timeout=5
+
 	exec 9>/var/lock/kdump
-	flock 9
+
+	flock -n 9
+	rc=$?
+
+	while [ $rc -ne 0 ]; do
+		echo "Another app is currently holding the kdump lock; waiting for it to exit..."
+		flock -w $timeout 9
+		rc=$?
+	done
 }
 
 # remove_cmdline_param <kernel cmdline> <param1> [<param2>] ... [<paramN>]


More information about the scm-commits mailing list