From 97733a2763a039359044b085d37e561d1c84d9f6 Mon Sep 17 00:00:00 2001 From: sullrich Date: Wed, 2 Dec 2009 23:51:33 -0500 Subject: Ensure process is running before killing --- etc/inc/config.inc | 3 ++- etc/inc/pfsense-utils.inc | 6 ++++-- etc/inc/pkg-utils.inc | 3 ++- etc/inc/service-utils.inc | 6 ++++-- etc/inc/vpn.inc | 6 ++++-- etc/inc/vslb.inc | 6 ++++-- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/etc/inc/config.inc b/etc/inc/config.inc index b778ab4..fb3c46e 100644 --- a/etc/inc/config.inc +++ b/etc/inc/config.inc @@ -1607,7 +1607,8 @@ function system_start_ftp_helpers() { require_once("interfaces.inc"); global $config, $g; - mwexec("/usr/bin/killall ftpsesame", true); + if(is_process_running("ftpsesame")) + mwexec("/usr/bin/killall ftpsesame", true); /* build an array of interfaces to work with */ $iflist = array("lan" => "lan"); diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 6a43b71..38fccd5 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -1881,7 +1881,8 @@ function WakeOnLan($addr, $mac) * NOTE: this command takes 5 seconds to run */ function gather_altq_queue_stats($dont_return_root_queues) { - mwexec("/usr/bin/killall -9 pfctl", true); + if(is_process_running("pfctl")) + mwexec("/usr/bin/killall -9 pfctl", true); $stats = `/sbin/pfctl -vvsq & /bin/sleep 5;/usr/bin/killall pfctl 2>/dev/null`; $stats_array = split("\n", $stats); $queue_stats = array(); @@ -3416,7 +3417,8 @@ function enable_rrd_graphing() { } function kill_traffic_collector() { - mwexec("/usr/bin/killall -9 rrdtool"); + if(is_process_running("rrdtool")) + mwexec("/usr/bin/killall -9 rrdtool"); mwexec("ps awwwux | grep '/[u]pdaterrd.sh' | awk '{print $2}' | xargs kill -9"); } diff --git a/etc/inc/pkg-utils.inc b/etc/inc/pkg-utils.inc index 370d8f5..89c1e34 100644 --- a/etc/inc/pkg-utils.inc +++ b/etc/inc/pkg-utils.inc @@ -549,7 +549,8 @@ function install_package_xml($pkg) { mwexec("/usr/sbin/clog -i -s 32768 {$g['varlog_path']}/{$pkg_info['logging']['logfilename']}"); chmod($g['varlog_path'] . '/' . $pkg_info['logging']['logfilename'], 0600); @fwrite($fd_log, "Adding text to file /etc/syslog.conf\n"); - mwexec("killall syslogd"); + if(is_process_running("syslogd")) + mwexec("killall syslogd"); system_syslogd_start(); } diff --git a/etc/inc/service-utils.inc b/etc/inc/service-utils.inc index 436926d..e9e2796 100644 --- a/etc/inc/service-utils.inc +++ b/etc/inc/service-utils.inc @@ -110,7 +110,8 @@ function stop_service($name) { eval($service['stopcmd']); } if(!($service['rcfile'] or $service['stopcmd'])) { - mwexec_bg("/usr/bin/killall {$service['executable']}"); + if(is_process_running($service['executable'])) + mwexec_bg("/usr/bin/killall {$service['executable']}"); return; } break; @@ -118,7 +119,8 @@ function stop_service($name) { } } /* finally if we get here lets simply kill the service name */ - mwexec_bg("/usr/bin/killall {$name}"); + if(is_process_running($name)) + mwexec_bg("/usr/bin/killall {$name}"); } function restart_service($name) { diff --git a/etc/inc/vpn.inc b/etc/inc/vpn.inc index 91e4951..719edd2 100644 --- a/etc/inc/vpn.inc +++ b/etc/inc/vpn.inc @@ -71,7 +71,8 @@ function vpn_ipsec_failover_configure() { fclose($fd); chmod("{$g['varetc_path']}/sasyncd.conf", 0600); - mwexec("killall sasyncd", true); + if(is_process_running("sasyncd")) + mwexec("killall sasyncd", true); /* launch sasyncd, oh wise one */ /* mwexec_bg("/usr/local/sbin/sasyncd -d -v -v -v"); */ @@ -1145,7 +1146,8 @@ function vpn_ipsec_force_reload() { $ipseccfg = $config['ipsec']; /* kill racoon */ - mwexec("/usr/bin/killall racoon", true); + if(is_process_running("racoon")) + mwexec("/usr/bin/killall racoon", true); /* wait for process to die */ sleep(4); diff --git a/etc/inc/vslb.inc b/etc/inc/vslb.inc index 8792386..ac1bd4d 100644 --- a/etc/inc/vslb.inc +++ b/etc/inc/vslb.inc @@ -199,12 +199,14 @@ EOD; if($should_start == 1) { fwrite($fd, $slbdconf); fclose($fd); - mwexec("/usr/bin/killall -9 slbd", true); + if(is_process_running("slbd")) + mwexec("/usr/bin/killall -9 slbd", true); sleep(2); /* startup slbd pointing it's config at /var/etc/slbd.conf with a polling interval of 5 seconds */ mwexec("/usr/local/sbin/slbd -c{$g['varetc_path']}/slbd.conf -r5000"); } else { - mwexec("/usr/bin/killall -9 slbd", true); + if(is_process_running("slbd")) + mwexec("/usr/bin/killall -9 slbd", true); fclose($fd); } -- cgit v1.1