Index

aPipes

MMO\core\classes · 1 symbol · generated 5 Oct 2026

class

aPipes

aPipes.php:18

Base class for feeding a subprocess's stdin and reading its stdout/stderr without blocking, used by

abstract class MMO\core\classes\aPipes
Namespace
MMO\core\classes
See
Process (via its platform-specific UnixPipes /, WindowsPipes subclasses). Input can be a plain string/scalar (buffered whole), a stream resource (read and written in CHUNK_SIZE chunks as the subprocess drains stdin), or an \Iterator yielding either of those (each item is fully written before the next is pulled).
// typically used indirectly, through Process: $p = new \MMO\core\server\Process('cat', null, null, "line1\nline2\n"); $p->run(); $p->getOutput(); // "line1\nline2\n" -- the input string was written to the subprocess's stdin via aPipes::write()

Index

CHUNK_SIZEChunk size (bytes) used when streaming a resource/iterator input to the subprocess.
TIMEOUT_PRECISION
blocked
input
inputBuffer
pipes
areOpen() abstract
close()Close every open pipe.
haveReadSupport() abstract
readAndWrite($blocking, $close) abstractRead what is available on the output pipes, and write what is pending on the input.
unblock()Switch every pipe (and the input resource, if any) to non-blocking mode, so reads/writes never stall waiting on the subprocess.
write()Write as much of the pending input to the subprocess's stdin (pipe 0) as it will currently accept without blocking, then return.
__construct($input)
__destruct()

Constants2

CHUNK_SIZE

Chunk size (bytes) used when streaming a resource/iterator input to the subprocess.

const CHUNK_SIZE = 16384

TIMEOUT_PRECISION

const TIMEOUT_PRECISION = 0.2

Properties4

blocked

protected $blocked = true

input

protected $input = null

inputBuffer

protected $inputBuffer = ''

pipes

$pipes = []

Methods8

areOpen()

abstractaPipes.php:23
abstract function areOpen(): bool
returnsboolwhether any pipe is still open

close()

aPipes.php:66

Close every open pipe.

function close()
returns

haveReadSupport()

abstractaPipes.php:20
abstract function haveReadSupport(): bool
returnsboolwhether the pipes can be read (a process started without any output capture cannot)

readAndWrite($blocking, $close)

abstractaPipes.php:31

Read what is available on the output pipes, and write what is pending on the input.

abstract function readAndWrite(bool $blocking, bool $close = false): array
$blockingboolwait for data to be available
$close = falseboolclose the pipes once read
returnsarraystring> what was read, by descriptor

unblock()

aPipes.php:96

Switch every pipe (and the input resource, if any) to non-blocking mode, so reads/writes never stall waiting on the subprocess. A no-op once already unblocked.

protected function unblock()
returns

write()

aPipes.php:115

Write as much of the pending input to the subprocess's stdin (pipe 0) as it will currently accept without blocking, then return. Call this repeatedly (typically from a select()-driven loop) until it returns null with the input fully drained -- it self-closes stdin once there is nothing left to write.

protected function write(): ?array
returnsnull | arraythe still-pending write-watch list (stdin's pipe, wrapped in an array) if more input remains to write later; null once stdin has been closed (input fully sent) or on a transient condition where nothing could be determined yet
throwsWhen an input iterator yields a value that is not a scalar or a stream resource

__construct($input)

aPipes.php:53
function __construct($input)
$inputa stream resource or \Iterator is written incrementally as the subprocess reads it; anything else is cast to string and buffered whole