Skip to content
You are reading v0.3, which is not the current release. Go to v0.4.

std::process::shell

Starting a shell.

This module is not std::process. It declares std::process::shell, and process.kh – which is in every build – is the module a caller imports. Two files declare this one, process_posix.kh and process_windows.kh, and exactly one is ever in a build.

The split is three functions rather than the whole module, which is the opposite of what std::net::socket does and deliberately so: khora_db::selected_for_target says that when two targets share ninety per cent of a file, the ten per cent belongs behind a function they both call. This is the ten per cent.

_posix rather than _linux, because nothing here is Linux’s: popen, pclose, system and the layout of a wait status are the same on macOS, and naming the file for one of them would have meant writing it twice.

The number that comes back from pclose and system is a wait status rather than an exit code – a packed word that has to be taken apart, which is what exit_status is for and what Windows has no need of.

The differences are all spelling and all Microsoft’s. popen and pclose are POSIX names that the UCRT does not export – a program that asks for them gets undefined symbol: popen out of the linker, which is measured rather than assumed – so the underscore-prefixed spellings are the only ones there are. system is ISO C and is itself on both.

What comes back is an exit code already, so there is no wait status to take apart.

Functions: open_pipe · close_pipe · run

pub fn open_pipe(command: String) -> Ptr

A stream reading what command writes to its standard output, or null.

The child’s standard error is not redirected, so it goes wherever this process’s does. Merging it in would need 2>&1 appended to the command line, which is a decision for the caller who wrote the rest of that line.

pub fn close_pipe(pipe: Ptr) -> Int

Waits for the pipe’s command to finish, and gives its exit status.

-1 if the wait itself failed, which is the one answer that is not an exit status.

pub fn run(command: String) -> Int

Runs command through the shell, waits, and gives its exit status.

-1 if the shell could not be started at all. A shell that started and could not find the command is not that: it exits 127, and 127 is an exit status like any other.

Khora 0.3.0built frombd964738afb6on 2026-10-17 20:41ZVersioningSecurityContributingReleasesSource