1 Star 0 Fork 58

yangcheng1203/dnf

forked from src-openEuler/dnf 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
unlock-pidfile-if-current-proccess-is-NOT-dnf.patch 1.44 KB
一键复制 编辑 原始数据 按行查看 历史
hanhuihui 提交于 2022-02-28 09:58 . round self-developed patch
From 7438ca37b6e688637a87cbdc87490e70a61e1829 Mon Sep 17 00:00:00 2001
From: fengtao40 <fengtao40@huawei.com>
Date: Sat, 13 Jun 2020 16:54:09 +0800
Subject: [PATCH] unlock-pidfile-if-current-proccess-is-NOT-dnf
---
dnf/lock.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/dnf/lock.py b/dnf/lock.py
index 13d8c27..589aa0a 100644
--- a/dnf/lock.py
+++ b/dnf/lock.py
@@ -32,6 +32,7 @@ import logging
import os
import threading
import time
+import re
logger = logging.getLogger("dnf")
@@ -106,6 +107,19 @@ class ProcessLock(object):
if old_pid == pid:
# already locked by this process
return pid
+
+ try:
+ with open('/proc/%d/status' % old_pid) as f:
+ for line in f:
+ if not re.match(r'Name:(.*)(dnf|yum)$', line, re.I):
+ os.write(fd, str(pid).encode('utf-8'))
+ return pid
+ except Exception as e:
+ msg = _('Malformed lock file found: %s.\n'
+ 'But pid in lock file is invalid '
+ 'Ensure no other dnf/yum process is running and '
+ 'remove the lock file manually.') % (self.target)
+ raise LockError(msg)
if not os.access('/proc/%d/stat' % old_pid, os.F_OK):
# locked by a dead process, write our pid
--
2.18.2
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yangcheng1203/dnf.git
git@gitee.com:yangcheng1203/dnf.git
yangcheng1203
dnf
dnf
master

搜索帮助