Rust processes: Difference between revisions

From wikinotes
Line 15: Line 15:
<syntaxhighlight lang="rust">
<syntaxhighlight lang="rust">
use std::env;
use std::env;
use std::process;


let args: Vec<String> = env::args().collect();  // commandline arguments
let args: Vec<String> = env::args().collect();  // commandline arguments
std::process::abort()    // exit process un-cleanly, no destructors called
std::process::exit()      // exit with returncode
std::process::id()        // process's pid
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- Current Process -->
</blockquote><!-- Current Process -->

Revision as of 02:12, 9 February 2023

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

use std::env;
use std::process;

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

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