logos.std.process

Module std · package logos-std

Types

structChild

struct Child

Handle to a spawned child process; owns the parent-side pipe fds.

Fields

pid: i32
stderr: i32
stdin: i32
stdout: i32

Methods

fn close_stderr(self: &mut Child) -> void

Closes the child’s stderr pipe. No-op if already closed.

fn close_stdin(self: &mut Child) -> void

Closes the child’s stdin pipe, signaling EOF to the child. No-op if already closed.

fn close_stdout(self: &mut Child) -> void

Closes the child’s stdout pipe. No-op if already closed.

fn read_stdout(self: &Child, buf: *mut u8, len: i64) -> i64

Reads up to len bytes from the child’s stdout pipe into buf. Returns bytes read (0 at EOF), or -1 if stdout was not piped at spawn time.

fn stderr_lines(self: &mut Child) -> LineReader

Returns a LineReader over the child’s stderr lines; same semantics as stdout_lines.

fn stdout_lines(self: &mut Child) -> LineReader

Returns a LineReader iterating lines from the child’s stdout. Requires stdout to have been piped at spawn time (pipe_stdout = true).

fn wait(self: &mut Child) -> ExitStatus

Blocks until the child exits and returns its ExitStatus. Closes any still-open stdin/stdout/stderr pipes before returning.

fn write_stdin(self: &Child, buf: *const u8, len: i64) -> i64

Writes up to len bytes from buf to the child’s stdin pipe. Returns bytes written, or -1 if stdin was not piped at spawn time.

structExitStatus

struct ExitStatus

Exit status of a terminated child process, wrapping the raw waitpid status word.

Fields

raw: i32

Methods

fn code(self: &ExitStatus) -> i32

Returns the exit code when exited() is true; 0 otherwise.

fn exited(self: &ExitStatus) -> bool

Returns true if the process exited normally (was not killed by a signal).

fn signal(self: &ExitStatus) -> i32

Returns the terminating signal number if killed by a signal; 0 otherwise.

fn success(self: &ExitStatus) -> bool

Returns true if the process exited normally with exit code 0.

structLineReader

struct LineReader

Buffered line iterator over a pipe fd, yielding lines with the \n terminator stripped. A trailing partial line at EOF is also yielded. Reads block (no reactor integration yet).

Implements: Iterator Drop

Fields

buf: *mut u8
cap: i64
eof: bool
fd: i32
head: i64
tail: i64

Methods

fn all(self: LineReader, pred: AllFn) -> bool
fn any(self: LineReader, pred: AnyFn) -> bool
fn chain(self: LineReader, other: ChainOther) -> ChainIter<LineReader, ChainOther, String>
fn collect(self: LineReader) -> C
fn count(self: LineReader) -> i64
fn drop(self: LineReader) -> void
fn enumerate(self: LineReader) -> EnumIter<LineReader, String>
fn filter(self: LineReader, pred: fn(String) -> bool) -> FilterIter<LineReader, String>
fn find(self: &mut LineReader, pred: FindFn) -> Option
fn find_map(self: LineReader, f: FindMapFn) -> Option
fn fold(self: LineReader, init: Acc, f: FoldFn) -> Acc
fn for_each(self: LineReader, f: EachFn) -> void
fn inspect(self: LineReader, visit: fn(String) -> void, zero: String) -> InspectIter<LineReader, String>
fn last(self: LineReader) -> Option
fn map(self: LineReader, f: MapFn) -> MapIter<LineReader, String, MapOut, MapFn>
fn max_by(self: LineReader, cmp: fn(String, String) -> i32) -> Option
fn min_by(self: LineReader, cmp: fn(String, String) -> i32) -> Option
fn next(self: &mut LineReader) -> Option
fn nth(self: &mut LineReader, n: i64) -> Option
fn peekable(self: LineReader) -> PeekableIter<LineReader, String>
fn position(self: &mut LineReader, pred: PosFn) -> Option
fn product(self: LineReader) -> S
fn reduce(self: LineReader, f: ReduceFn) -> Option
fn skip(self: LineReader, n: i64) -> SkipIter<LineReader, String>
fn skip_while(self: LineReader, pred: fn(String) -> bool, zero: String) -> SkipWhileIter<LineReader, String>
fn step_by(self: LineReader, step: i64, zero: String) -> StepByIter<LineReader, String>
fn sum(self: LineReader) -> S
fn take(self: LineReader, n: i64) -> TakeIter<LineReader, String>
fn take_while(self: LineReader, pred: fn(String) -> bool, zero: String) -> TakeWhileIter<LineReader, String>
fn try_fold(self: LineReader, init: Acc, f: TryFoldFn) -> ControlFlow
fn try_for_each(self: LineReader, f: TryEachFn) -> ControlFlow
fn zip(self: LineReader, other: ZipOther) -> ZipIter<LineReader, ZipOther, String, ZipOtherItem>

Functions

fnspawn

fn spawn(argv: *const *const u8, pipe_stdin: bool, pipe_stdout: bool, pipe_stderr: bool) -> Child

Spawns a child process via fork + execvp. argv must be a null-terminated array of NUL-terminated C strings; argv[0] is the program. Each pipe_* flag redirects that child fd through a pipe held open on the returned Child. On fork failure returns a Child with pid -1; if exec fails the child exits with code 127.

fnspawn_simple

fn spawn_simple(argv: *const *const u8) -> Child

Spawns a child with no pipes; the child inherits the parent’s stdio fds.