bugfix: remove .rename_device.lock file when process does not exist
This commit is contained in:
parent
a0d1e7101c
commit
9a65c92440
@ -20,7 +20,7 @@ Requires: gawk \
|
|||||||
Name: initscripts
|
Name: initscripts
|
||||||
Summary: Basic support for legacy System V init scripts
|
Summary: Basic support for legacy System V init scripts
|
||||||
Version: 10.04
|
Version: 10.04
|
||||||
Release: 1
|
Release: 2
|
||||||
|
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
|
|
||||||
@ -91,6 +91,7 @@ Patch9003: bugfix-network-need-chkconfig-on.patch
|
|||||||
Patch9004: bugfix-restart-network-warning.patch
|
Patch9004: bugfix-restart-network-warning.patch
|
||||||
Patch9005: new-network-fork-to-start-dhcp.patch
|
Patch9005: new-network-fork-to-start-dhcp.patch
|
||||||
Patch9006: exec-udevadm-settle-when-network-start.patch
|
Patch9006: exec-udevadm-settle-when-network-start.patch
|
||||||
|
Patch9007: remove-rename_device_lock-when-process-does-not-exis.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
This package provides basic support for legacy System V init scripts, and some
|
This package provides basic support for legacy System V init scripts, and some
|
||||||
@ -358,6 +359,12 @@ fi
|
|||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Dec 15 2020 zengwefeng<zwfeng@huawei.com> - 10.04-2
|
||||||
|
- Type:bugfix
|
||||||
|
- ID:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:remove .rename_device.lock when proccess does not exist
|
||||||
|
|
||||||
* Fri Jul 24 2020 hanzhijun<hanzhijun1@huawei.com> - 10.04-1
|
* Fri Jul 24 2020 hanzhijun<hanzhijun1@huawei.com> - 10.04-1
|
||||||
- Type:enhancement
|
- Type:enhancement
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
45
remove-rename_device_lock-when-process-does-not-exis.patch
Normal file
45
remove-rename_device_lock-when-process-does-not-exis.patch
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
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 first;
|
||||||
|
}
|
||||||
|
|
||||||
|
+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
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user