Files
Dan Gohman 4e2599b729 Run the tests on Rust 1.48, and check compilation of tests and examples on more targets (#465)
* Fix the tests to run on 1.48.

This puts the benchmarks behind a `criterion` cfg, so add
`--cfg=criterion` to RUSTFLAGS when running cargo bench.

An MSRV of 1.48 enables us to support users such as async-io, which also
has an MSRV of 1.48.

* Add a rust-version field.

This prints a warning under Rust 1.48, but only when rustix is the
top-level build; when rustix is a dependency, it doesn't warn, so this
seems ok.
2022-12-01 11:42:09 -08:00

148 lines
5.2 KiB
Rust

//! A command which prints out information about the process it runs in.
use rustix::io;
#[cfg(all(feature = "process", feature = "param"))]
#[cfg(not(windows))]
fn main() -> io::Result<()> {
use rustix::param::*;
use rustix::process::*;
println!("Pid: {}", getpid().as_raw_nonzero());
println!("Parent Pid: {}", Pid::as_raw(getppid()));
println!("Group Pid: {}", getpgrp().as_raw_nonzero());
if let Some(ppid) = getppid() {
println!(
"Parent Group Pid: {}",
getpgid(Some(ppid)).unwrap().as_raw_nonzero()
);
}
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());
#[cfg(not(target_os = "fuchsia"))]
{
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()
);
#[cfg(not(target_os = "fuchsia"))]
{
println!("Cpu Limit: {:?}", getrlimit(Resource::Cpu));
println!("Fsize Limit: {:?}", getrlimit(Resource::Fsize));
println!("Data Limit: {:?}", getrlimit(Resource::Data));
println!("Stack Limit: {:?}", getrlimit(Resource::Stack));
#[cfg(not(target_os = "haiku"))]
println!("Core Limit: {:?}", getrlimit(Resource::Core));
#[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
println!("Rss Limit: {:?}", getrlimit(Resource::Rss));
#[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
println!("Nproc Limit: {:?}", getrlimit(Resource::Nproc));
#[cfg(not(target_os = "solaris"))]
println!("Nofile Limit: {:?}", getrlimit(Resource::Nofile));
#[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
println!("Memlock Limit: {:?}", getrlimit(Resource::Memlock));
#[cfg(not(target_os = "openbsd"))]
println!("As Limit: {:?}", getrlimit(Resource::As));
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
println!("Locks Limit: {:?}", getrlimit(Resource::Locks));
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
println!("Sigpending Limit: {:?}", getrlimit(Resource::Sigpending));
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
println!("Msgqueue Limit: {:?}", getrlimit(Resource::Msgqueue));
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
println!("Nice Limit: {:?}", getrlimit(Resource::Nice));
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
println!("Rtprio Limit: {:?}", getrlimit(Resource::Rtprio));
#[cfg(not(any(
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
println!("Rttime Limit: {:?}", getrlimit(Resource::Rttime));
}
#[cfg(any(
all(target_os = "android", target_pointer_width = "64"),
target_os = "linux"
))]
println!("Execfn: {:?}", linux_execfn());
Ok(())
}
#[cfg(any(windows, not(all(feature = "process", feature = "param"))))]
fn main() -> io::Result<()> {
unimplemented!()
}