From d07aa0c8a9f658c72d44276c6bb3540eabaac94d Mon Sep 17 00:00:00 2001 From: zengweifeng Date: Tue, 15 Dec 2020 11:21:05 +0800 Subject: [PATCH] bugfix: remove .rename_device.lock when process does not exist --- initscripts.spec | 9 +++- ...vice_lock-when-process-does-not-exis.patch | 45 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 remove-rename_device_lock-when-process-does-not-exis.patch diff --git a/initscripts.spec b/initscripts.spec index b3f55cd..60df24a 100644 --- a/initscripts.spec +++ b/initscripts.spec @@ -20,7 +20,7 @@ Requires: gawk \ Name: initscripts Summary: Basic support for legacy System V init scripts Version: 10.04 -Release: 1 +Release: 2 License: GPLv2 @@ -91,6 +91,7 @@ Patch9003: bugfix-network-need-chkconfig-on.patch Patch9004: bugfix-restart-network-warning.patch Patch9005: new-network-fork-to-start-dhcp.patch Patch9006: exec-udevadm-settle-when-network-start.patch +Patch9007: remove-rename_device_lock-when-process-does-not-exis.patch %description This package provides basic support for legacy System V init scripts, and some @@ -358,6 +359,12 @@ fi # ============================================================================= %changelog +* Tue Dec 15 2020 zengwefeng - 10.04-2 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:remove .rename_device.lock when proccess does not exist + * Fri Jul 24 2020 hanzhijun - 10.04-1 - Type:enhancement - ID:NA diff --git a/remove-rename_device_lock-when-process-does-not-exis.patch b/remove-rename_device_lock-when-process-does-not-exis.patch new file mode 100644 index 0000000..df70840 --- /dev/null +++ b/remove-rename_device_lock-when-process-does-not-exis.patch @@ -0,0 +1,45 @@ +From 882677f72fd4541a9e1aa4b8c40d8095f1be3536 Mon Sep 17 00:00:00 2001 +From: 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 + -- Gitee