mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-19 19:15:22 +00:00
interfaces: try to wait for dhclient exit, take 1
PR: https://forum.opnsense.org/index.php?topic=4682.0
This commit is contained in:
parent
f0f65fc9ad
commit
844d6b506a
@ -2453,15 +2453,7 @@ function kill_dhclient_process($interface)
|
||||
return;
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
while ((($pid = find_dhclient_process($interface)) != 0) && ($i < 3)) {
|
||||
/* 3rd time make it die for sure */
|
||||
$sig = ($i == 2 ? 'KILL' : 'TERM');
|
||||
exec(sprintf('/bin/kill -%s %s', $sig, $pid));
|
||||
sleep(1);
|
||||
$i++;
|
||||
}
|
||||
unset($i);
|
||||
killbypid(find_dhclient_process($interface), 'TERM', true);
|
||||
}
|
||||
|
||||
function interface_vlan_mtu_configured($realhwif, $mtu)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2015-2016 Franco Fichtner <franco@opnsense.org>
|
||||
Copyright (C) 2015-2017 Franco Fichtner <franco@opnsense.org>
|
||||
Copyright (C) 2004-2007 Scott Ullrich <sullrich@gmail.com>
|
||||
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
||||
All rights reserved.
|
||||
@ -41,12 +41,14 @@ function killbyname($procname, $sig = 'TERM')
|
||||
|
||||
function killbypid($pidfile, $sig = 'TERM', $waitforit = false)
|
||||
{
|
||||
if (!isvalidpid($pidfile)) {
|
||||
if (isvalidpid($pidfile)) {
|
||||
mwexecf('/bin/pkill -%s -F %s', array($sig, $pidfile));
|
||||
} elseif (is_numeric($pidfile) && $pidfile > 0) {
|
||||
mwexecf('/bin/kill -%s %s', array($sig, $pidfile));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
mwexecf('/bin/pkill -%s -F %s', array($sig, $pidfile));
|
||||
|
||||
if (!$waitforit) {
|
||||
return;
|
||||
}
|
||||
@ -58,11 +60,13 @@ function killbypid($pidfile, $sig = 'TERM', $waitforit = false)
|
||||
|
||||
function isvalidpid($pidfile)
|
||||
{
|
||||
if (!file_exists($pidfile)) {
|
||||
return false;
|
||||
if (file_exists($pidfile)) {
|
||||
return mwexecf('/bin/pgrep -nF %s', $pidfile, true) == 0;
|
||||
} elseif (is_numeric($pidfile) && $pidfile > 0) {
|
||||
return mwexecf('/bin/kill -0 %s', $pidfile, true) == 0;
|
||||
}
|
||||
|
||||
return mwexecf('/bin/pgrep -nF %s', $pidfile, true) == 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_process_running($process)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user