#process-running #binary #translated #detect #rosetta #arm64 #universal

is_proc_translated

Detect if the current process is running as a translated binary under Rosetta

2 releases

0.1.1 Oct 7, 2022
0.1.0 Oct 7, 2022

#70 in macOS and iOS APIs

Download history 8341/week @ 2024-07-22 8413/week @ 2024-07-29 6794/week @ 2024-08-05 6110/week @ 2024-08-12 5521/week @ 2024-08-19 6757/week @ 2024-08-26 5441/week @ 2024-09-02 7415/week @ 2024-09-09 7887/week @ 2024-09-16 7517/week @ 2024-09-23 8568/week @ 2024-09-30 8078/week @ 2024-10-07 4924/week @ 2024-10-14 5963/week @ 2024-10-21 6383/week @ 2024-10-28 6435/week @ 2024-11-04

23,815 downloads per month
Used in 5 crates (via nix_rs)

MIT/Apache

7KB

is_proc_translated

github crates.io docs.rs

Detect if the current process is running as a translated binary under Rosetta.

[dependencies]
is_proc_translated = "0.1"

Using is_proc_translated

use std::process::Command;

use is_proc_translated::is_proc_translated;

fn main() {
    // Force executing the arm64 slice of a Universal Binary.
    let status = if is_proc_translated() {
        Command::new("arch")
            .arg("-arm64")
            .arg("buck")
            .arg("build")
            .status()
            .expect("failed to execute process")
    } else {
        Command::new("buck")
            .arg("build")
            .status()
            .expect("failed to execute process")
    };

    println!("process finished with: {status}");
}

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies