Pipes

EsPipeCreate

void EsPipeCreate(EsHandle *readEnd, EsHandle *writeEnd);

Creates a pipe. Returns the read and write ends. Close both handles with EsHandleClose.

EsPipeRead

size_t EsPipeRead(EsHandle pipe, void *buffer, size_t bytes, bool allowShortReads);

If buffer is null, then the data is discarded. If allowShortReads is false, then the call will block until the buffer is full or there are no writers; if allowShortReads is true, then the call will block until the buffer is non-empty or there are no writers. Note that the modes are equivalent iff bytes is 0 or 1.

EsPipeWrite

size_t EsPipeWrite(EsHandle pipe, const void *buffer, size_t bytes);

Writes bytes to the pipe. Blocks until all bytes are written or there are no readers. Returns the number of bytes written.