diff options
author | Renato Botelho <renato.botelho@bluepex.com> | 2010-09-08 10:20:04 -0300 |
---|---|---|
committer | Renato Botelho <renato.botelho@bluepex.com> | 2010-09-08 10:20:04 -0300 |
commit | 8c04b1ae0a9bf0d41746824c3d34d24ba2d54d9b (patch) | |
tree | cecf571643c08858880695d453d4f199649423f9 /etc/inc/util.inc | |
parent | 86385ef36f81052afc3febdbce3a3af49373c7a6 (diff) | |
parent | 245da5436bc5a30d6c65d68dbd54a56dca1ec896 (diff) | |
download | pfsense-8c04b1ae0a9bf0d41746824c3d34d24ba2d54d9b.zip pfsense-8c04b1ae0a9bf0d41746824c3d34d24ba2d54d9b.tar.gz |
Merge remote branch 'mainline/master' into inc
Conflicts:
etc/inc/filter.inc
etc/inc/pkg-utils.inc
etc/inc/service-utils.inc
etc/inc/system.inc
etc/inc/vpn.inc
Diffstat (limited to 'etc/inc/util.inc')
-rw-r--r-- | etc/inc/util.inc | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 8a9db4f..a8e9c01 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -50,27 +50,22 @@ function isvalidpid($pid) { } function is_process_running($process) { - $running = shell_exec("/bin/pgrep -x {$process}"); + $output = ""; + exec("/bin/pgrep -x {$process}", $output, $retval); - return !empty($running); + return (intval($retval) == 0); } function isvalidproc($proc) { - $running = is_process_running($proc); - if (intval($running) >= 1) - return true; - else - return false; + return is_process_running($proc); } /* sigkill a process by pid file */ /* return 1 for success and 0 for a failure */ function sigkillbypid($pidfile, $sig) { - if (is_file($pidfile)) { - $pid = trim(file_get_contents($pidfile)); - if(isvalidpid($pid)) - return mwexec("/bin/kill -s $sig {$pid}", true); - } + if (is_file($pidfile)) + return mwexec("/bin/pkill -{$sig} -F {$pidfile}", true); + return 0; } @@ -142,6 +137,36 @@ function unlock($cfglckkey = 0) { return; } +function send_event($cmd) { + global $g; + + $fd = fsockopen($g['event_address']); + if ($fd) { + fwrite($fd, $cmd); + $resp = fread($fd, 4096); + if ($resp != "OK\n") + log_error("send_event: sent {$cmd} got {$resp}"); + fclose($fd); + } +} + +function send_multiple_events($cmds) { + global $g; + + if (!is_array($cmds)) + return; + $fd = fsockopen($g['event_address']); + if ($fd) { + foreach ($cmds as $cmd) { + fwrite($fd, $cmd); + $resp = fread($fd, 4096); + if ($resp != "OK\n") + log_error("send_event: sent {$cmd} got {$resp}"); + } + fclose($fd); + } +} + function refcount_init($reference) { $shmid = shmop_open($reference, "c", 0644, 10); shmop_write($shmid, 0, 0); @@ -1181,8 +1206,6 @@ function start_devd() { exec("/sbin/devd"); sleep(1); - if(file_exists("{$g['tmp_path']}/rc.linkup")) - unlink("{$g['tmp_path']}/rc.linkup"); } function is_interface_mismatch() { @@ -1212,7 +1235,7 @@ function is_interface_mismatch() { /* sync carp entries to other firewalls */ function carp_sync_client() { global $g; - touch($g['tmp_path'] . "/filter_sync"); + send_event("filter sync"); } /****f* util/isAjax |