std1.0.0-beta-7 SafeC docs

std :: ipc::pipe

Struct std::Pipe

#include <std/ipc/pipe.h> source

struct Pipe {
    long long read_fd;
    long long write_fd;
}

Fields

§long long read_fdsource
§long long write_fdsource

Methods

§int init()source · definition

Creates a new pipe in place (fills read_fd/write_fd). Returns 0 on success, -1 on failure.

§long long read([]unsigned char buf)source · definition

Reads up to 'count' bytes from the pipe's read end into 'buf'. Returns the number of bytes read (0 means the write end was closed and the pipe is drained — EOF), or -1 on error.

§long long write([]const unsigned char buf)source · definition

Writes up to 'count' bytes from 'buf' to the pipe's write end. Returns the number of bytes written, or -1 on error.

§int set_read_nonblocking()source · definition

Puts the read end into non-blocking mode (pairs with std::Reactor — await_fd(p.read_fd, SCHED_READ) once this returns 0). Returns 0 on success, -1 on failure.

§int set_write_nonblocking()source · definition

Puts the write end into non-blocking mode. Returns 0 on success, -1 on failure.

§int close_read()source · definition

Closes the read end. Safe to call once; closing twice is undefined the same way double-close(2) is on any platform.

§int close_write()source · definition

Closes the write end. A reader blocked in read() (or awaiting SCHED_READ on read_fd) sees EOF (read() returns 0) once this runs and the pipe is drained.