#include "posix.h" #include #include #include fx_status fx_pipe_create(fx_iostream **reader, fx_iostream **writer) { int fds[2]; int err = pipe(fds); if (err != 0) { return fx_status_from_errno(errno, FX_ERR_NOT_SUPPORTED); } fx_iostream *r = fx_iostream_create(FX_STREAM_READ, fds[0], true); fx_iostream *w = fx_iostream_create(FX_STREAM_WRITE, fds[1], true); if (!r || !w) { fx_iostream_unref(r); fx_iostream_unref(w); close(fds[0]); close(fds[1]); return FX_ERR_NO_MEMORY; } *reader = r; *writer = w; return FX_SUCCESS; }