Projet

Général

Profil

« Précédent | Suivant » 

Révision d9d1bd20

Ajouté par Renato Botelho il y a plus de 9 ans

Implement a function to kill dhclient process, sometimes it takes a little time to die, so use a sleep(1) there

Voir les différences:

etc/inc/interfaces.inc
1242 1242
		}
1243 1243
		break;
1244 1244
	case "dhcp":
1245
		$pid = find_dhclient_process($realif);
1246
		if($pid)
1247
			posix_kill($pid, SIGTERM);
1248
		sleep(1);
1245
		kill_dhclient_process($realif);
1249 1246
		unlink_if_exists("{$g['varetc_path']}/dhclient_{$interface}.conf");
1250 1247
		if(does_interface_exist("$realif")) {
1251 1248
			mwexec("/sbin/ifconfig " . escapeshellarg($realif) . " delete", true);
......
2801 2798
	return intval($pid);
2802 2799
}
2803 2800

  
2801
function kill_dhclient_process($interface) {
2802
	if (empty($interface) || !does_interface_exist($interface))
2803
		return;
2804

  
2805
	$i = 0;
2806
	while ((($pid = find_dhclient_process($interface)) != 0) && ($i < 3)) {
2807
		/* 3rd time make it die for sure */
2808
		$sig = ($i == 2 ? SIGKILL : SIGTERM);
2809
		posix_kill($pid, $sig);
2810
		sleep(1);
2811
		$i++;
2812
	}
2813
	unset($i);
2814
}
2815

  
2804 2816
function find_dhcp6c_process($interface) {
2805 2817
	global $g;
2806 2818

  

Formats disponibles : Unified diff