1 Star 0 Fork 22

src-openeuler-fork/initscripts

forked from src-openEuler/initscripts 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
remove-rename_device_lock-when-process-does-not-exis.patch 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
Apricity 提交于 2022-01-20 08:57 . update initscript version to 10.12
From 882677f72fd4541a9e1aa4b8c40d8095f1be3536 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Mon, 14 Dec 2020 20:52:47 +0800
Subject: [PATCH] remove-rename_device_lock-when-process-does-not-exist.patch
---
src/rename_device.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/rename_device.c b/src/rename_device.c
index c39f447..5e49bbd 100644
--- a/src/rename_device.c
+++ b/src/rename_device.c
@@ -278,6 +278,13 @@ char *get_config_by_hwaddr(char *hwaddr, char *current) {
return name;
}
+int pid_exist(int pid)
+{
+ char proc_dir[32];
+ sprintf(proc_dir, "/proc/%d/", pid);
+ return !access(proc_dir, F_OK);
+}
+
void take_lock() {
int count = 0;
int lockfd;
@@ -309,8 +316,12 @@ void take_lock() {
close(fd);
pid = atoi(buf);
if (pid && pid != 1) {
- kill(pid,SIGKILL);
- }
+ if (pid_exist(pid))
+ kill(pid,SIGKILL);
+ else
+ if (unlink(LOCKFILE) != 0)
+ break;
+ }
}
usleep(100000);
continue;
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler-fork/initscripts.git
git@gitee.com:src-openeuler-fork/initscripts.git
src-openeuler-fork
initscripts
initscripts
master

搜索帮助