Giter Club home page Giter Club logo

limits-rs's Introduction

limits-rs

Build Status Crate Docs License

A Rust library for determining the limits that an operating system enforces on a given particular process.

Operating systems support

In its current implementation, this crate allows convenient read of the /proc/<pid>/limits file on GNU/Linux. On any other platform, the provided methods will return an error so that the user can decide what to do in the absence of information about limits.

Support for other operating systems and platforms may be added on demand. Feel free to file an issue or make a PR!

Examples

Checking the limits for a specific PID

use limits_rs::get_pid_limits;

// Let's check what the CPU time hard limit is for process `1`.
let limits = get_pid_limits(1).unwrap();
let max_cpu_time_hard_limit = limits.max_cpu_time.hard;

// This will print either:
// - "Some(x)" if there is a limit, where `x` is the limit itself.
// - "None" if it is "unlimited".
println!("{}", max_cpu_time_hard_limit);

Checking the limits for our own PID

use limits_rs::get_pid_limits;

// Let's check what the open files soft limit is for our own process.
let limits = get_own_limits().unwrap();
let max_open_files_soft_limit = limits.max_open_files.soft;

// This will print either:
// - "Some(x)" if there is a limit, where `x` is the limit itself.
// - "None" if it is "unlimited".
println!("{}", max_open_files_soft_limit);

Supported "limitable" properties

GNU/Linux

The properties currently tracked by limits-rs::linux::Limits are:

  • max_cpu_time
  • max_file_size
  • max_data_size
  • max_stack_size
  • max_core_file_size
  • max_resident_set
  • max_processes
  • max_open_files
  • max_locked_memory
  • max_address_space
  • max_file_locks
  • max_pending_signals
  • max_msgqueue_size
  • max_nice_priority
  • max_realtime_priority
  • max_realtime_timeout

Other operating systems

As said before, support for other operating systems and platforms may be added on demand. Feel free to file an issue or make a PR!

License

Scriptful is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT, and COPYRIGHT for details.

limits-rs's People

Contributors

aesedepece avatar psiace avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.