summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2008-10-10 01:58:41 +0000
committerNarayan Desai <desai@mcs.anl.gov>2008-10-10 01:58:41 +0000
commit88b0cd44b7b311b17cbb2576882b73180cdc071d (patch)
tree18f6da44ead8ed5d43338e699a5c502b33fa2a08 /src
parent2ff9955ad576e8e3b5d0b0891c8ee38e7ab23aa2 (diff)
downloadbcfg2-88b0cd44b7b311b17cbb2576882b73180cdc071d.tar.gz
bcfg2-88b0cd44b7b311b17cbb2576882b73180cdc071d.tar.bz2
bcfg2-88b0cd44b7b311b17cbb2576882b73180cdc071d.zip
Improve error checking for lockfiles
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4938 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rwxr-xr-xsrc/sbin/bcfg216
1 files changed, 9 insertions, 7 deletions
diff --git a/src/sbin/bcfg2 b/src/sbin/bcfg2
index 7e78935ba..b2d203a1a 100755
--- a/src/sbin/bcfg2
+++ b/src/sbin/bcfg2
@@ -307,14 +307,16 @@ class Client:
if not self.setup['omit-lock-check']:
#check lock here
- lockfile = open(LOCKFILE, 'w')
try:
- fcntl.lockf(lockfile.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
- except IOError:
- #otherwise exit and give a warning to the user
- self.fatal_error("An other instance of bcfg2 is running. If you what to bypass the check, run with %s option" %
- (Bcfg2.Options.OMIT_LOCK_CHECK.cmd))
- return(1)
+ lockfile = open(LOCKFILE, 'w')
+ try:
+ fcntl.lockf(lockfile.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
+ except IOError:
+ #otherwise exit and give a warning to the user
+ self.fatal_error("An other instance of bcfg2 is running. If you what to bypass the check, run with %s option" %
+ (Bcfg2.Options.OMIT_LOCK_CHECK.cmd))
+ except:
+ self.logger.error("Failed to open lockfile")
# execute the said configuration
self.tools.Execute()