mirror of
https://github.com/openharmony/third_party_rust_rustix.git
synced 2026-07-19 14:53:33 -04:00
99fd6e5ccc
Add support for glibc's y2038 APIs in the libc backend. The musl and android targets are not y2038 compatible on 32-bit platforms, however in musl's case, this will be fixed when Rust itself is updated to musl 1.2, and in android's case, this is because android itself does not intend to be y2038-compatible on 32-bit platforms. This strengthen's rustix's y2038 stance to: support y2038 compatibility on platforms which have support for this.
102 lines
3.4 KiB
Rust
102 lines
3.4 KiB
Rust
//! A command which prints out information about the process it runs in.
|
|
|
|
use rustix::io;
|
|
|
|
#[cfg(feature = "process")]
|
|
#[cfg(not(windows))]
|
|
fn main() -> io::Result<()> {
|
|
use rustix::process::*;
|
|
|
|
println!("Pid: {}", getpid().as_raw_nonzero());
|
|
println!("Parent Pid: {}", Pid::as_raw(getppid()));
|
|
println!("Uid: {}", getuid().as_raw());
|
|
println!("Gid: {}", getgid().as_raw());
|
|
#[cfg(any(
|
|
all(target_os = "android", target_pointer_width = "64"),
|
|
target_os = "linux"
|
|
))]
|
|
{
|
|
let (a, b) = linux_hwcap();
|
|
println!("Linux hwcap: {:#x}, {:#x}", a, b);
|
|
}
|
|
println!("Page size: {}", page_size());
|
|
println!("Clock ticks/sec: {}", clock_ticks_per_second());
|
|
println!("Uname: {:?}", uname());
|
|
println!("Process group priority: {}", getpriority_pgrp(None)?);
|
|
println!("Process priority: {}", getpriority_process(None)?);
|
|
println!("User priority: {}", getpriority_user(Uid::ROOT)?);
|
|
println!(
|
|
"Current working directory: {}",
|
|
getcwd(Vec::new())?.to_string_lossy()
|
|
);
|
|
println!("Cpu Limit: {:?}", getrlimit(Resource::Cpu));
|
|
println!("Fsize Limit: {:?}", getrlimit(Resource::Fsize));
|
|
println!("Data Limit: {:?}", getrlimit(Resource::Data));
|
|
println!("Stack Limit: {:?}", getrlimit(Resource::Stack));
|
|
println!("Core Limit: {:?}", getrlimit(Resource::Core));
|
|
println!("Rss Limit: {:?}", getrlimit(Resource::Rss));
|
|
println!("Nproc Limit: {:?}", getrlimit(Resource::Nproc));
|
|
println!("Nofile Limit: {:?}", getrlimit(Resource::Nofile));
|
|
println!("Memlock Limit: {:?}", getrlimit(Resource::Memlock));
|
|
#[cfg(not(target_os = "openbsd"))]
|
|
println!("As Limit: {:?}", getrlimit(Resource::As));
|
|
#[cfg(not(any(
|
|
target_os = "freebsd",
|
|
target_os = "ios",
|
|
target_os = "macos",
|
|
target_os = "netbsd",
|
|
target_os = "openbsd",
|
|
)))]
|
|
println!("Locks Limit: {:?}", getrlimit(Resource::Locks));
|
|
#[cfg(not(any(
|
|
target_os = "freebsd",
|
|
target_os = "ios",
|
|
target_os = "macos",
|
|
target_os = "netbsd",
|
|
target_os = "openbsd",
|
|
)))]
|
|
println!("Sigpending Limit: {:?}", getrlimit(Resource::Sigpending));
|
|
#[cfg(not(any(
|
|
target_os = "freebsd",
|
|
target_os = "ios",
|
|
target_os = "macos",
|
|
target_os = "netbsd",
|
|
target_os = "openbsd",
|
|
)))]
|
|
println!("Msgqueue Limit: {:?}", getrlimit(Resource::Msgqueue));
|
|
#[cfg(not(any(
|
|
target_os = "freebsd",
|
|
target_os = "ios",
|
|
target_os = "macos",
|
|
target_os = "netbsd",
|
|
target_os = "openbsd",
|
|
)))]
|
|
println!("Nice Limit: {:?}", getrlimit(Resource::Nice));
|
|
#[cfg(not(any(
|
|
target_os = "freebsd",
|
|
target_os = "ios",
|
|
target_os = "macos",
|
|
target_os = "netbsd",
|
|
target_os = "openbsd",
|
|
)))]
|
|
println!("Rtprio Limit: {:?}", getrlimit(Resource::Rtprio));
|
|
#[cfg(not(any(
|
|
target_os = "emscripten",
|
|
target_os = "freebsd",
|
|
target_os = "android",
|
|
target_os = "ios",
|
|
target_os = "macos",
|
|
target_os = "netbsd",
|
|
target_os = "openbsd",
|
|
)))]
|
|
println!("Rttime Limit: {:?}", getrlimit(Resource::Rttime));
|
|
#[cfg(any(target_os = "android", target_os = "linux"))]
|
|
println!("Execfn: {:?}", linux_execfn());
|
|
Ok(())
|
|
}
|
|
|
|
#[cfg(any(windows, not(feature = "process")))]
|
|
fn main() -> io::Result<()> {
|
|
unimplemented!()
|
|
}
|