std::os¶
Status: experimental
Operating-system identity.
API details and source¶
The implementation source contains the complete declarations and implementation notes. The table below lists canonical Gossamer call signatures; every item name links directly to its implementation file.
| Item | Canonical signature or declaration | Description |
|---|---|---|
arch |
fn arch() -> String |
Returns the target CPU architecture (e.g. "x86_64"). |
Child |
type Child |
Handle to a still-running child supporting wait / kill. |
Pipeline |
type Pipeline |
Multi-stage subprocess pipeline (stdout-to-stdin chain). |
Signal |
type Signal |
Portable signal selector (Term/Kill/Stop/Cont/Hup/Int/Usr1/Usr2/Pipe/Quit). |
kill |
fn kill(pid: i64) -> bool |
Best-effort SIGTERM by pid; returns true on success. |
kill_group |
fn kill_group(pid: i64) -> bool |
Send SIGTERM to the entire process group (Unix); best-effort TerminateProcess on Windows. |
pipeline_run |
fn pipeline_run(commands: Vec<String>) -> Result<process::Output, errors::Error> |
Run a Vec |
run |
fn run(program: String, args: Vec<String>) -> Result<process::Output, errors::Error> |
One-shot: runs a program with args, captures stdout/stderr, returns Result<{stdout, stderr, code}, String>. |
signal |
fn signal(pid: i64, signum: i64) -> bool |
Send an arbitrary signal number to a pid; returns true on success. |
spawn |
fn spawn(program: String, args: Vec<String>) -> Result<i64, errors::Error> |
Non-blocking launch; returns the child PID as Result |
spawn_piped |
fn spawn_piped(program: String, args: Vec<String>) -> Result<process::Child, errors::Error> |
Spawns a child with piped stdin/stdout; returns Result |
wait_timeout |
fn wait_timeout(pid: i64, ms: i64) -> i64 |
Wait up to N ms for a pid to exit; returns exit code, -1 on timeout, -2 on error. |
family |
fn family() -> String |
Returns "unix" or "windows" for the running OS family. |
Notifier |
type Notifier |
Returned by on(sig); supports wait / try_wait. |
Signal |
type Signal |
Opaque signal name; constructors live in sigs. |
on |
fn on(signum: i64) -> os::signal::Notifier |
Subscribes to a signal; returns a Notifier. |
try_wait |
fn try_wait(notifier: os::signal::Notifier) -> bool |
Non-blocking poll: returns true if the subscribed signal has fired. |
wait |
fn wait(notifier: os::signal::Notifier) -> () |
Blocks the calling goroutine until the subscribed signal fires. |
current_gid |
fn current_gid() -> i64 |
gid of the current process user, or -1 on non-unix. |
current_home |
fn current_home() -> String |
Home directory of the current process user. |
current_name |
fn current_name() -> String |
Login name of the current process user, or empty string. |
current_uid |
fn current_uid() -> i64 |
uid of the current process user, or -1 on non-unix. |
lookup_name |
fn lookup_name(name: String) -> i64 |
uid for the user with the given login name, or -1 if not found. |
lookup_uid |
fn lookup_uid(uid: i64) -> String |
Login name for the given uid, or empty string if unknown. |