Rust processes

From wikinotes

Documentation

std::env (process environment) https://doc.rust-lang.org/std/env/index.html
std::process (manage processes) https://doc.rust-lang.org/std/process/index.html

Current Process

General

use std::env;

let args: Vec<String> = env::args().collect();  // commandline arguments
std::env::set_current_dir()                     // change cwd

Environment

use std::env;

std::env::set_var()      // set environment variable
std::env::var()          // get environment variable
std::env::remove_var()   // remove environment variable

Exit Process

use std::process;

std::process::abort()     // exit process un-cleanly, no destructors called
std::process::exit()      // exit with returncode
std::process::id()        // process's pid