The process: its arguments, the processors it can run on, its hash seed, other programs run and waited for, and the ways to end it early. Those are exit, through the C library, and trap, core's builtin (core::process::trap), which stops it at once.
Re-exports
trap | Re-export of a builtin. |
Types
Args | The arguments the process was started with, the program's name first, as C's main received them. |
Exit | How a child process ended: exit with a status, or a signal. |
Stdio! | Where a child's standard input, output or error comes from or goes: this process's own stream (Inherit, what a Command! starts with), /dev/null (Null), a new pipe whose other end the Child! holds (Pipe), or a file this process opened (File), which spawn closes once the child has its own copy. |
Command! | A program to run, its arguments, and how it runs: its standard streams (stdin, stdout, stderr), its environment (env, env_remove, env_clear) and its working directory (current_dir). |
Child! | A program Command!::spawn started, running until it is waited for, with this process's end of each of its streams that is a pipe. |
Polled! | What Child!::try_wait found: the child still running, or how it ended. |
Captured! | What Command!::output and Child!::wait_with_output capture: how the child ended, and what it wrote to its standard output and error. |
Functions
pipe_end | This process's end of a pipe spawn made, as a File!, or nothing for -1. |
read_both | Reads a into into_a and b into into_b until both end, a read from whichever can be read without waiting at a time; both are closed. |
read_some | One read from end into into: end back while it has more, else closed, at its end or at an error, which goes to failed unless one is there already. |
descriptor_of | The descriptor of end, or -1 for none, which poll passes over. |
close_end | Closes a pipe's end, when there is one. |
status_of | The error of a call that returns 0 or an errno. |
exit_of | How a child ended, from what the C runtime's wait returns for one that has. |
available_parallelism | The number of processors the process may run on, at least 1: how many of its threads can run at once without waiting for one another. |
hash_seed | The process's hash seed: 128 bits the process drew from the operating system when it started (getentropy), the same for every call in the process and different from one run to the next. |
exit | Ends the process with status after C's exit runs its handlers and flushes C's own streams, once: the first call runs exit, and a call from another thread meanwhile never returns, waiting for the first to end the process (C leaves two exits at once undefined). |
Function declarations
fn pipe_endsource
unsafe fn pipe_end(fd: i32) -> Option[File!] { ... }
This process's end of a pipe spawn made, as a File!, or nothing for -1. Caller: fd is -1 or a descriptor nothing else owns.
fn read_bothsource
fn read_both(a: Option[File!], b: Option[File!], &into_a: Buffer!, &into_b: Buffer!) -> Result[(), Error] { ... }
Reads a into into_a and b into into_b until both end, a read from whichever can be read without waiting at a time; both are closed. The first read error is returned once both are closed.
fn read_somesource
fn read_some(end: Option[File!], &into: Buffer!, &failed: Option[Error]) -> Option[File!] { ... }
One read from end into into: end back while it has more, else closed, at its end or at an error, which goes to failed unless one is there already.
fn descriptor_ofsource
fn descriptor_of(&end: Option[File!]) -> i32 { ... }
The descriptor of end, or -1 for none, which poll passes over.
fn close_endsource
fn close_end(end: Option[File!]) { ... }
Closes a pipe's end, when there is one.
fn status_ofsource
fn status_of(code: i32) -> Result[(), Error] { ... }
The error of a call that returns 0 or an errno. Used by Child!'s kill and signal; not meant for direct use.
fn exit_ofsource
fn exit_of(result: i64) -> Result[Exit, Error] { ... }
How a child ended, from what the C runtime's wait returns for one that has. Used by Child!'s waits; not meant for direct use.
fn available_parallelismsource
fn available_parallelism() -> usize { ... }
The number of processors the process may run on, at least 1: how many of its threads can run at once without waiting for one another. That is the processors of its CPU affinity mask (taskset, sched_setaffinity) where the C library reports the mask, else the processors online.
fn hash_seedsource
fn hash_seed() -> Seed { ... }
The process's hash seed: 128 bits the process drew from the operating system when it started (getentropy), the same for every call in the process and different from one run to the next. The seed to make maps with (OwnedMap!::new, HashMap!::new, Domain!::new), so that no one who does not know it can choose keys that collide (core::hash); and since it changes from run to run, so does the order a HashMap! lists its keys in.
fn exitsource
fn exit(status: i32) -> ! { ... }
Ends the process with status after C's exit runs its handlers and flushes C's own streams, once: the first call runs exit, and a call from another thread meanwhile never returns, waiting for the first to end the process (C leaves two exits at once undefined). Like trap, it breaks no invariant: nothing after a call runs in the thread that made it. Linear values still live are not consumed, so whatever they own is left for the operating system to reclaim.