Note (quoted from `man 7 pipe` on debian linux):
"On some systems (but not Linux), pipes are bidirectional: data can be transmitted in both directions between the pipe ends. According to POSIX.1-2001, pipes only need to be unidirectional. Portable applications should avoid reliance on bidirectional pipe semantics."
Linux pipes are NOT bidirectional.
Also, it appears to me that the use of fifo (named) pipes in php is pretty pointless as there appears to be NO way of determining whether opening (let alone reading) from it will block. stream_select SHOULD be able to accomplish this, unfortunatly you cannot get to this point because even trying to OPEN a pipe for read will block until there is a writer.
I even tried to use popen("cat $name_of_pipe", 'r'), and even it blocked until it was opened for write by another process.
posix_mkfifo
(PHP 4, PHP 5)
posix_mkfifo — Erzeugt eine "FIFO special"-Datei (named pipe)
Beschreibung
$pathname
, int $mode
)posix_mkfifo() erzeugt eine spezielle FIFO-Datei, die im Dateisystem existiert und als bidirektionaler Kommunikationsendpunkt für Prozesse agiert.
Parameter-Liste
-
pathname -
Der Pfad zur FIFO-Datei.
-
mode -
Der zweite Parameter
modemuss in oktaler Schreibweise angegeben werden (z.B. 0644). Die Zugriffsberechtigungen des neu erzeugten FIFO hängen auch von der Einstellung der aktuellen umask() ab. Die Zugriffsberechtigungen der erzeugten Datei sind (mode & ~umask).
Rückgabewerte
Gibt bei Erfolg TRUE zurück. Im Fehlerfall wird FALSE zurückgegeben.
Anmerkungen
Hinweis: Wenn Safe Mode aktiviert ist, überprüft PHP, ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst.
posix_mkfifo
18-May-2007 11:12