1 Star 0 Fork 24

luofeng14/dhcp

forked from src-openEuler/dhcp 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
bugfix-dhclient-check-if-pid-was-held.patch 1.28 KB
一键复制 编辑 原始数据 按行查看 历史
eaglegai 提交于 2020-07-22 11:38 . update dhcp version to 4.4.2
From 569ca7918daa63832207e0d96f7d0b2d78300850 Mon Sep 17 00:00:00 2001
From: zhanglu <zhanglu37@huawei.com>
Date: Thu, 27 Feb 2020 20:47:22 +0800
Subject: [PATCH] dhcp: solve start dhclient when last pid was held.
Signed-off-by: zhanglu <zhanglu37@huawei.com>
---
client/dhclient.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/client/dhclient.c b/client/dhclient.c
index 9f8ba06..eff3444 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -774,15 +774,26 @@ main(int argc, char **argv) {
}
} else {
FILE *pidfp = NULL;
+ FILE *commfp = NULL;
long temp = 0;
pid_t dhcpid = 0;
int dhc_running = 0;
char procfn[256] = "";
+ char pidname_path[256] = "";
+ char pidname[256] = "";
if ((pidfp = fopen(path_dhclient_pid, "re")) != NULL) {
if ((fscanf(pidfp, "%ld", &temp)==1) && ((dhcpid=(pid_t)temp) > 0)) {
snprintf(procfn,256,"/proc/%u",dhcpid);
- dhc_running = (access(procfn, F_OK) == 0);
+ snprintf(pidname_path,256,"%s/comm",procfn);
+
+ if (access(procfn, F_OK) == 0) {
+ if ((commfp = fopen(pidname_path, "r")) != NULL) {
+ fscanf(commfp, "%s", pidname);
+ dhc_running = (strncmp("dhclient", pidname, strlen("dhclient")) == 0);
+ fclose(commfp);
+ }
+ }
}
fclose(pidfp);
--
2.19.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/luofeng14/dhcp.git
git@gitee.com:luofeng14/dhcp.git
luofeng14
dhcp
dhcp
master

搜索帮助