|
|
|
@ -412,6 +412,7 @@ class YumModule(YumDnf):
|
|
|
|
|
raise e
|
|
|
|
|
|
|
|
|
|
def is_lockfile_pid_valid(self):
|
|
|
|
|
try:
|
|
|
|
|
try:
|
|
|
|
|
with open(self.lockfile, 'r') as f:
|
|
|
|
|
oldpid = int(f.readline())
|
|
|
|
@ -419,8 +420,6 @@ class YumModule(YumDnf):
|
|
|
|
|
# invalid data
|
|
|
|
|
os.unlink(self.lockfile)
|
|
|
|
|
return False
|
|
|
|
|
except (IOError, OSError) as e:
|
|
|
|
|
self.module.fail_json(msg="Failure opening %s: %s" % (self.lockfile, to_native(e)))
|
|
|
|
|
|
|
|
|
|
if oldpid == os.getpid():
|
|
|
|
|
# that's us?
|
|
|
|
@ -436,7 +435,9 @@ class YumModule(YumDnf):
|
|
|
|
|
os.unlink(self.lockfile)
|
|
|
|
|
return False
|
|
|
|
|
except IOError:
|
|
|
|
|
# either /proc is not mounted or the process is already dead
|
|
|
|
|
try:
|
|
|
|
|
# check the state of the process
|
|
|
|
|
os.kill(oldpid, 0)
|
|
|
|
|
except OSError as e:
|
|
|
|
|
if e.errno == errno.ESRCH:
|
|
|
|
@ -445,6 +446,9 @@ class YumModule(YumDnf):
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
self.module.fail_json(msg="Unable to check PID %s in %s: %s" % (oldpid, self.lockfile, to_native(e)))
|
|
|
|
|
except (IOError, OSError) as e:
|
|
|
|
|
# lockfile disappeared?
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# another copy seems to be running
|
|
|
|
|
return True
|
|
|
|
|