diff --git a/initscripts.spec b/initscripts.spec index 6d867a49615edd94fd9e2b6ad081bd7870313f5f..d8e4814b282675064299f8dce32becc9ebf3cb81 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 @@ -89,6 +89,7 @@ Patch4: bugfix-network-need-chkconfig-on.patch Patch5: bugfix-restart-network-warning.patch Patch6: new-network-fork-to-start-dhcp.patch Patch7: exec-udevadm-settle-when-network-start.patch +Patch8: remove-rename_device_lock-when-process-does-not-exist.patch %description This package provides basic support for legacy System V init scripts, and some @@ -356,6 +357,12 @@ fi # ============================================================================= %changelog +* Tue Dec 29 2020 zengwefeng - 10.04-2 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:remove .rename_device.lock when process does not exist + * Wed Aug 19 2020 gaihuiying - 10.04-1 - Type:enhancement - ID:NA diff --git a/remove-rename_device_lock-when-process-does-not-exist.patch b/remove-rename_device_lock-when-process-does-not-exist.patch new file mode 100644 index 0000000000000000000000000000000000000000..df70840e6a764273987a1d21ce8ac85c4dd51d83 --- /dev/null +++ b/remove-rename_device_lock-when-process-does-not-exist.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 +