summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2014-09-09 17:52:34 -0300
committerRenato Botelho <garga@FreeBSD.org>2014-09-09 17:52:34 -0300
commitd9d1bd20c8caa5f12bb95b0af7fced1ec75473eb (patch)
tree9d8ec242fb2baa2f6a482c7eca1b85eedbde02a8 /etc
parent397e40d52ab44daee99de73970e0ae2e70cce346 (diff)
downloadpfsense-d9d1bd20c8caa5f12bb95b0af7fced1ec75473eb.zip
pfsense-d9d1bd20c8caa5f12bb95b0af7fced1ec75473eb.tar.gz
Implement a function to kill dhclient process, sometimes it takes a little time to die, so use a sleep(1) there
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/interfaces.inc20
1 files changed, 16 insertions, 4 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index 045ca17..a4390ad 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -1242,10 +1242,7 @@ function interface_bring_down($interface = "wan", $destroy = false, $ifacecfg =
}
break;
case "dhcp":
- $pid = find_dhclient_process($realif);
- if($pid)
- posix_kill($pid, SIGTERM);
- sleep(1);
+ kill_dhclient_process($realif);
unlink_if_exists("{$g['varetc_path']}/dhclient_{$interface}.conf");
if(does_interface_exist("$realif")) {
mwexec("/sbin/ifconfig " . escapeshellarg($realif) . " delete", true);
@@ -2801,6 +2798,21 @@ function find_dhclient_process($interface) {
return intval($pid);
}
+function kill_dhclient_process($interface) {
+ if (empty($interface) || !does_interface_exist($interface))
+ return;
+
+ $i = 0;
+ while ((($pid = find_dhclient_process($interface)) != 0) && ($i < 3)) {
+ /* 3rd time make it die for sure */
+ $sig = ($i == 2 ? SIGKILL : SIGTERM);
+ posix_kill($pid, $sig);
+ sleep(1);
+ $i++;
+ }
+ unset($i);
+}
+
function find_dhcp6c_process($interface) {
global $g;
OpenPOWER on IntegriCloud