PHP Doku:: Check whether a message queue exists - function.msg-queue-exists.html

Verlauf / Chronik / History: (16) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzErweiterungen zur ProzesskontrolleSemaphore, Shared Memory and IPCSemaphore Funktionenmsg_queue_exists

Ein Service von Reinhard Neidl - Webprogrammierung.

Semaphore Funktionen

<<msg_get_queue

msg_receive>>

msg_queue_exists

(PHP 5 >= 5.3.0)

msg_queue_existsCheck whether a message queue exists

Beschreibung

bool msg_queue_exists ( int $key )

Checks whether the message queue key exists.

Parameter-Liste

key

Queue key.

Rückgabewerte

Gibt bei Erfolg TRUE zurück. Im Fehlerfall wird FALSE zurückgegeben.

Siehe auch


Ein BenutzerBeitrag:
- Beiträge aktualisieren...
jaredm
11.12.2009 1:31
A workaround for those not yet running 5.3 on *nix:

<?php
function queue_exists($key) {
    if(
function_exists("msg_queue_exists")) {
        return
msg_queue_exists($key);
    } else {
       
$aQueues = array();
       
exec("ipcs -q | grep \"^[0-9]\" | cut -d \" \" -f 1", $aQueues);
        if(
in_array($key,$aQueues)) return true;
        else return
false;
    }
}
?>

Maybe a bit slow and kludgey, but it works.



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)