Git Product home page Git Product logo

rlimit's Introduction

rlimit's People

Contributors

googollee avatar jtracey avatar manasugi avatar musicinmybrain avatar nmathewson avatar nugine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rlimit's Issues

Windows resource limits

Currently, this crate has no items when targeting windows.

Add support for windows resource limits.

And then change the description.

A simple wrapper for getrlimit and setrlimit.

Resource limits

cross-compilation broken with latest release

Cross compilation is somewhat broken in 0.10.0 due to the use of a build-script to set cfg flags.

To reproduce, on linux (no need for a full CC toolchain with clang, rustc is enough):

rustup target add x86_64-apple-darwin
cargo check --target x86_64-apple-darwin

A build-script was introduced, I assume to reduce lengthy cfg!(). Sadly it doesn't work as intended. target_os, target_env &co inside a build-script correspond to the host, not the real target, as the build-script is always compiled to be run on the host. This leads to rlimit__has_prlimit64 being set, based on the linux host having that feature, when the target is actually macOS, which shouldn't have it (it seems)

deb cargo on github actions can't build rlimit

Howdy!

I added rlimit to my project, feroxbuster, today and it works perfectly, so thank you for that! In order to build a .deb package on CI, I use cargo deb and Github Actions. For some reason, cargo deb fails to build on the pipeline.

I'm not implying that there is something wrong with rlimit, as the same build command works on my local dev machine. I just don't see anything in the logs below that would help me identify what the CI build machine is missing. I'm really just posting this here to see if you recognize the problem.

Thanks again!

2020-11-07T23:12:46.2912823Z    Compiling rlimit v0.5.2
2020-11-07T23:12:46.3437218Z error: unexpected token: `0.`
2020-11-07T23:12:46.3439020Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:193:32
2020-11-07T23:12:46.3439700Z     |
2020-11-07T23:12:46.3440141Z 193 |                     match self.0.$check(rhs.0) {
2020-11-07T23:12:46.3440650Z     |                     ----- -----^^
2020-11-07T23:12:46.3440999Z     |                     |     |    |
2020-11-07T23:12:46.3454929Z     |                     |     |    unexpected token
2020-11-07T23:12:46.3455635Z     |                     |     help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3456227Z     |                     while parsing this match expression
2020-11-07T23:12:46.3456596Z ...
2020-11-07T23:12:46.3456967Z 269 | impl_arithmetic!(Add, add, checked_add);
2020-11-07T23:12:46.3458039Z     | ---------------------------------------- in this macro invocation
2020-11-07T23:12:46.3458454Z     |
2020-11-07T23:12:46.3459238Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3459776Z 
2020-11-07T23:12:46.3460110Z error: unexpected token: `0.`
2020-11-07T23:12:46.3461075Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:198:31
2020-11-07T23:12:46.3461719Z     |
2020-11-07T23:12:46.3461998Z 198 |                     Self(self.0.$method(rhs.0))
2020-11-07T23:12:46.3462491Z     |                          -----^^
2020-11-07T23:12:46.3462764Z     |                          |    |
2020-11-07T23:12:46.3463093Z     |                          |    unexpected token
2020-11-07T23:12:46.3463600Z     |                          help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3464036Z ...
2020-11-07T23:12:46.3464403Z 269 | impl_arithmetic!(Add, add, checked_add);
2020-11-07T23:12:46.3465048Z     | ---------------------------------------- in this macro invocation
2020-11-07T23:12:46.3465340Z     |
2020-11-07T23:12:46.3466115Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3489141Z 
2020-11-07T23:12:46.3489735Z error: unexpected token: `0.`
2020-11-07T23:12:46.3490838Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:211:32
2020-11-07T23:12:46.3491445Z     |
2020-11-07T23:12:46.3491699Z 211 |                     match self.0.$check(rhs) {
2020-11-07T23:12:46.3492180Z     |                     ----- -----^^
2020-11-07T23:12:46.3492467Z     |                     |     |    |
2020-11-07T23:12:46.3492774Z     |                     |     |    unexpected token
2020-11-07T23:12:46.3493228Z     |                     |     help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3493729Z     |                     while parsing this match expression
2020-11-07T23:12:46.3494276Z ...
2020-11-07T23:12:46.3494643Z 269 | impl_arithmetic!(Add, add, checked_add);
2020-11-07T23:12:46.3495368Z     | ---------------------------------------- in this macro invocation
2020-11-07T23:12:46.3495706Z     |
2020-11-07T23:12:46.3496424Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3496903Z 
2020-11-07T23:12:46.3497208Z error: unexpected token: `0.`
2020-11-07T23:12:46.3498043Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:216:31
2020-11-07T23:12:46.3498642Z     |
2020-11-07T23:12:46.3498943Z 216 |                     Self(self.0.$method(rhs))
2020-11-07T23:12:46.3499420Z     |                          -----^^
2020-11-07T23:12:46.3499673Z     |                          |    |
2020-11-07T23:12:46.3499994Z     |                          |    unexpected token
2020-11-07T23:12:46.3500447Z     |                          help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3500842Z ...
2020-11-07T23:12:46.3501141Z 269 | impl_arithmetic!(Add, add, checked_add);
2020-11-07T23:12:46.3501735Z     | ---------------------------------------- in this macro invocation
2020-11-07T23:12:46.3502052Z     |
2020-11-07T23:12:46.3502768Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3503190Z 
2020-11-07T23:12:46.3533596Z error: unexpected token: `0.`
2020-11-07T23:12:46.3534940Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:193:32
2020-11-07T23:12:46.3535505Z     |
2020-11-07T23:12:46.3535921Z 193 |                     match self.0.$check(rhs.0) {
2020-11-07T23:12:46.3536341Z     |                     ----- -----^^
2020-11-07T23:12:46.3536649Z     |                     |     |    |
2020-11-07T23:12:46.3536958Z     |                     |     |    unexpected token
2020-11-07T23:12:46.3537561Z     |                     |     help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3538075Z     |                     while parsing this match expression
2020-11-07T23:12:46.3538411Z ...
2020-11-07T23:12:46.3538935Z 270 | impl_arithmetic!(Sub, sub, checked_sub);
2020-11-07T23:12:46.3539597Z     | ---------------------------------------- in this macro invocation
2020-11-07T23:12:46.3539884Z     |
2020-11-07T23:12:46.3540657Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3541198Z 
2020-11-07T23:12:46.3541550Z error: unexpected token: `0.`
2020-11-07T23:12:46.3542515Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:198:31
2020-11-07T23:12:46.3543105Z     |
2020-11-07T23:12:46.3543436Z 198 |                     Self(self.0.$method(rhs.0))
2020-11-07T23:12:46.3543921Z     |                          -----^^
2020-11-07T23:12:46.3544192Z     |                          |    |
2020-11-07T23:12:46.3544527Z     |                          |    unexpected token
2020-11-07T23:12:46.3545019Z     |                          help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3545478Z ...
2020-11-07T23:12:46.3545844Z 270 | impl_arithmetic!(Sub, sub, checked_sub);
2020-11-07T23:12:46.3546436Z     | ---------------------------------------- in this macro invocation
2020-11-07T23:12:46.3546775Z     |
2020-11-07T23:12:46.3547546Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3548057Z 
2020-11-07T23:12:46.3548384Z error: unexpected token: `0.`
2020-11-07T23:12:46.3549285Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:211:32
2020-11-07T23:12:46.3549929Z     |
2020-11-07T23:12:46.3550250Z 211 |                     match self.0.$check(rhs) {
2020-11-07T23:12:46.3550866Z     |                     ----- -----^^
2020-11-07T23:12:46.3551132Z     |                     |     |    |
2020-11-07T23:12:46.3551440Z     |                     |     |    unexpected token
2020-11-07T23:12:46.3552003Z     |                     |     help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3552505Z     |                     while parsing this match expression
2020-11-07T23:12:46.3552791Z ...
2020-11-07T23:12:46.3553128Z 270 | impl_arithmetic!(Sub, sub, checked_sub);
2020-11-07T23:12:46.3553730Z     | ---------------------------------------- in this macro invocation
2020-11-07T23:12:46.3554061Z     |
2020-11-07T23:12:46.3554795Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3555220Z 
2020-11-07T23:12:46.3555524Z error: unexpected token: `0.`
2020-11-07T23:12:46.3556401Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:216:31
2020-11-07T23:12:46.3556998Z     |
2020-11-07T23:12:46.3557299Z 216 |                     Self(self.0.$method(rhs))
2020-11-07T23:12:46.3557751Z     |                          -----^^
2020-11-07T23:12:46.3558021Z     |                          |    |
2020-11-07T23:12:46.3558276Z     |                          |    unexpected token
2020-11-07T23:12:46.3558728Z     |                          help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3559130Z ...
2020-11-07T23:12:46.3559473Z 270 | impl_arithmetic!(Sub, sub, checked_sub);
2020-11-07T23:12:46.3560066Z     | ---------------------------------------- in this macro invocation
2020-11-07T23:12:46.3560378Z     |
2020-11-07T23:12:46.3561091Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3561512Z 
2020-11-07T23:12:46.3561812Z error: unexpected token: `0.`
2020-11-07T23:12:46.3562706Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:193:32
2020-11-07T23:12:46.3563300Z     |
2020-11-07T23:12:46.3563683Z 193 |                     match self.0.$check(rhs.0) {
2020-11-07T23:12:46.3564152Z     |                     ----- -----^^
2020-11-07T23:12:46.3564358Z     |                     |     |    |
2020-11-07T23:12:46.3564665Z     |                     |     |    unexpected token
2020-11-07T23:12:46.3565114Z     |                     |     help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3565808Z     |                     while parsing this match expression
2020-11-07T23:12:46.3566186Z ...
2020-11-07T23:12:46.3566550Z 271 | impl_arithmetic!(Mul, mul, checked_mul);
2020-11-07T23:12:46.3567188Z     | ---------------------------------------- in this macro invocation
2020-11-07T23:12:46.3567548Z     |
2020-11-07T23:12:46.3568269Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3568781Z 
2020-11-07T23:12:46.3658820Z error: unexpected token: `0.`
2020-11-07T23:12:46.3660194Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:198:31
2020-11-07T23:12:46.3660860Z     |
2020-11-07T23:12:46.3661232Z 198 |                     Self(self.0.$method(rhs.0))
2020-11-07T23:12:46.3661732Z     |                          -----^^
2020-11-07T23:12:46.3662008Z     |                          |    |
2020-11-07T23:12:46.3662341Z     |                          |    unexpected token
2020-11-07T23:12:46.3662828Z     |                          help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3663198Z ...
2020-11-07T23:12:46.3663581Z 271 | impl_arithmetic!(Mul, mul, checked_mul);
2020-11-07T23:12:46.3664256Z     | ---------------------------------------- in this macro invocation
2020-11-07T23:12:46.3664605Z     |
2020-11-07T23:12:46.3665384Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3665846Z 
2020-11-07T23:12:46.3666174Z error: unexpected token: `0.`
2020-11-07T23:12:46.3667127Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:211:32
2020-11-07T23:12:46.3668018Z     |
2020-11-07T23:12:46.3668517Z 211 |                     match self.0.$check(rhs) {
2020-11-07T23:12:46.3669011Z     |                     ----- -----^^
2020-11-07T23:12:46.3669310Z     |                     |     |    |
2020-11-07T23:12:46.3669641Z     |                     |     |    unexpected token
2020-11-07T23:12:46.3670081Z     |                     |     help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3670617Z     |                     while parsing this match expression
2020-11-07T23:12:46.3670982Z ...
2020-11-07T23:12:46.3671348Z 271 | impl_arithmetic!(Mul, mul, checked_mul);
2020-11-07T23:12:46.3672000Z     | ---------------------------------------- in this macro invocation
2020-11-07T23:12:46.3672351Z     |
2020-11-07T23:12:46.3673122Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3673586Z 
2020-11-07T23:12:46.3673941Z error: unexpected token: `0.`
2020-11-07T23:12:46.3674898Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:216:31
2020-11-07T23:12:46.3675534Z     |
2020-11-07T23:12:46.3675854Z 216 |                     Self(self.0.$method(rhs))
2020-11-07T23:12:46.3676283Z     |                          -----^^
2020-11-07T23:12:46.3676555Z     |                          |    |
2020-11-07T23:12:46.3676903Z     |                          |    unexpected token
2020-11-07T23:12:46.3677389Z     |                          help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3677806Z ...
2020-11-07T23:12:46.3678188Z 271 | impl_arithmetic!(Mul, mul, checked_mul);
2020-11-07T23:12:46.3678849Z     | ---------------------------------------- in this macro invocation
2020-11-07T23:12:46.3679184Z     |
2020-11-07T23:12:46.3679991Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3680509Z 
2020-11-07T23:12:46.3680852Z error: unexpected token: `0.`
2020-11-07T23:12:46.3681814Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:193:32
2020-11-07T23:12:46.3682449Z     |
2020-11-07T23:12:46.3682724Z 193 |                     match self.0.$check(rhs.0) {
2020-11-07T23:12:46.3683207Z     |                     ----- -----^^
2020-11-07T23:12:46.3683506Z     |                     |     |    |
2020-11-07T23:12:46.3683835Z     |                     |     |    unexpected token
2020-11-07T23:12:46.3684322Z     |                     |     help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3684858Z     |                     while parsing this match expression
2020-11-07T23:12:46.3685234Z ...
2020-11-07T23:12:46.3685600Z 272 | impl_arithmetic!(Div, div, checked_div);
2020-11-07T23:12:46.3686181Z     | ---------------------------------------- in this macro invocation
2020-11-07T23:12:46.3686525Z     |
2020-11-07T23:12:46.3687299Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3687832Z 
2020-11-07T23:12:46.3688224Z error: unexpected token: `0.`
2020-11-07T23:12:46.3689186Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:198:31
2020-11-07T23:12:46.3689845Z     |
2020-11-07T23:12:46.3690172Z 198 |                     Self(self.0.$method(rhs.0))
2020-11-07T23:12:46.3690659Z     |                          -----^^
2020-11-07T23:12:46.3690877Z     |                          |    |
2020-11-07T23:12:46.3691207Z     |                          |    unexpected token
2020-11-07T23:12:46.3691693Z     |                          help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3692132Z ...
2020-11-07T23:12:46.3692496Z 272 | impl_arithmetic!(Div, div, checked_div);
2020-11-07T23:12:46.3693145Z     | ---------------------------------------- in this macro invocation
2020-11-07T23:12:46.3693496Z     |
2020-11-07T23:12:46.3694599Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3695063Z 
2020-11-07T23:12:46.3695393Z error: unexpected token: `0.`
2020-11-07T23:12:46.3696371Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:211:32
2020-11-07T23:12:46.3697014Z     |
2020-11-07T23:12:46.3697381Z 211 |                     match self.0.$check(rhs) {
2020-11-07T23:12:46.3697812Z     |                     ----- -----^^
2020-11-07T23:12:46.3698093Z     |                     |     |    |
2020-11-07T23:12:46.3698440Z     |                     |     |    unexpected token
2020-11-07T23:12:46.3698925Z     |                     |     help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3699468Z     |                     while parsing this match expression
2020-11-07T23:12:46.3699831Z ...
2020-11-07T23:12:46.3700200Z 272 | impl_arithmetic!(Div, div, checked_div);
2020-11-07T23:12:46.3700848Z     | ---------------------------------------- in this macro invocation
2020-11-07T23:12:46.3701133Z     |
2020-11-07T23:12:46.3701926Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3702449Z 
2020-11-07T23:12:46.3702777Z error: unexpected token: `0.`
2020-11-07T23:12:46.3703732Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:216:31
2020-11-07T23:12:46.3704312Z     |
2020-11-07T23:12:46.3704632Z 216 |                     Self(self.0.$method(rhs))
2020-11-07T23:12:46.3705110Z     |                          -----^^
2020-11-07T23:12:46.3705382Z     |                          |    |
2020-11-07T23:12:46.3705707Z     |                          |    unexpected token
2020-11-07T23:12:46.3706209Z     |                          help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3706638Z ...
2020-11-07T23:12:46.3707094Z 272 | impl_arithmetic!(Div, div, checked_div);
2020-11-07T23:12:46.3707697Z     | ---------------------------------------- in this macro invocation
2020-11-07T23:12:46.3708039Z     |
2020-11-07T23:12:46.3708810Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3709316Z 
2020-11-07T23:12:46.3709641Z error: unexpected token: `0.`
2020-11-07T23:12:46.3710538Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:247:26
2020-11-07T23:12:46.3711183Z     |
2020-11-07T23:12:46.3711553Z 247 |                       self.0.$check(rhs.0).map(Self)
2020-11-07T23:12:46.3712046Z     |                       -----^^
2020-11-07T23:12:46.3712319Z     |                       |    |
2020-11-07T23:12:46.3712648Z     |                       |    unexpected token
2020-11-07T23:12:46.3713128Z     |                       help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3713544Z ...
2020-11-07T23:12:46.3713845Z 279 | / delegate_arithmetic! {@checked
2020-11-07T23:12:46.3714233Z 280 | |     checked_add,
2020-11-07T23:12:46.3714594Z 281 | |     checked_sub,
2020-11-07T23:12:46.3714931Z 282 | |     checked_mul,
2020-11-07T23:12:46.3715254Z 283 | |     checked_div,
2020-11-07T23:12:46.3715540Z 284 | | }
2020-11-07T23:12:46.3716023Z     | |_- in this macro invocation
2020-11-07T23:12:46.3716295Z     |
2020-11-07T23:12:46.3717064Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3717575Z 
2020-11-07T23:12:46.3717901Z error: unexpected token: `0.`
2020-11-07T23:12:46.3718800Z    --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.5.2/src/unix/rlim_type.rs:262:31
2020-11-07T23:12:46.3719458Z     |
2020-11-07T23:12:46.3719801Z 262 |                       Self(self.0.$wrap(rhs.0))
2020-11-07T23:12:46.3720283Z     |                            -----^^
2020-11-07T23:12:46.3720568Z     |                            |    |
2020-11-07T23:12:46.3720975Z     |                            |    unexpected token
2020-11-07T23:12:46.3721462Z     |                            help: try parenthesizing the first index: `(self.0).`
2020-11-07T23:12:46.3721879Z ...
2020-11-07T23:12:46.3722180Z 286 | / delegate_arithmetic! {@wrapping
2020-11-07T23:12:46.3722596Z 287 | |     wrapping_add,
2020-11-07T23:12:46.3722933Z 288 | |     wrapping_sub,
2020-11-07T23:12:46.3723286Z 289 | |     wrapping_mul,
2020-11-07T23:12:46.3723621Z 290 | |     wrapping_div,
2020-11-07T23:12:46.3723911Z 291 | | }
2020-11-07T23:12:46.3724398Z     | |_- in this macro invocation
2020-11-07T23:12:46.3724668Z     |
2020-11-07T23:12:46.3725435Z     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020-11-07T23:12:46.3725962Z 
2020-11-07T23:12:46.4297727Z error: aborting due to 18 previous errors
2020-11-07T23:12:46.4301312Z 
2020-11-07T23:12:46.4337349Z error: could not compile `rlimit`.
2020-11-07T23:12:46.4342069Z 

proc limits

Provide an api to read /proc/{pid}/limits and report them as a single struct.

rlimit 0.8.2 breaks with older Rust versions

As part of our CI process, we test to make sure that our code builds with older versions of Rust. When we try to build rlimit 0.8.2 with Rust 1.53, we get a bunch of these.

error[E0658]: panicking in constants is unstable
    --> src/bindings.rs:1031:15
     |
1031 | const _: () = assert!(0 <= libc::RLIMIT_STACK && libc::RLIMIT_STACK < 128);
     |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

We're downgrading to 0.7 for now: we have no other choice, since 0.8.1 and 0.8.0 have been yanked.

Is it intentional that rlimit no longer supports older versions of Rust?

Final review before 1.0

The current APIs are nearly stable.

Remaining questions:

  • rlimit will not add cgroups API. cgroups-rs is recommanded now.
  • Is it ok to use u64 as the rlim type for all platforms? (Yes)
  • The signature of rlimit::prlimit seems sightly strange. Is there a better way?
  • setmaxstdio(u32::MAX) can lead to crash. Should it be a feature or a bug?

Related issues:

failed to allocate an alternative stack

When I run the test, it sometimes panicked.
I am sure that it is related to RLIMIT_AS, but the limit (128MB, 256MB) is high enough. Why?
src/test.rs#L13

$ export RUST_BACKTRACE=1;cargo test
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running target/debug/deps/rlimit-5a874300cf08dd30

running 3 tests
test test::test_eq ... ok
test test::test_set_get ... ok
thread '<unnamed>' panicked at 'failed to allocate an alternative stack', src/libstd/sys/unix/stack_overflow.rs:136:13
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:70
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:58
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:478
   5: std::panicking::begin_panic
             at src/libstd/panicking.rs:412
   6: std::sys::unix::thread::Thread::new::thread_start
             at src/libstd/sys/unix/stack_overflow.rs:136
             at src/libstd/sys/unix/stack_overflow.rs:148
             at src/libstd/sys/unix/stack_overflow.rs:162
             at src/libstd/sys/unix/stack_overflow.rs:15
             at src/libstd/sys_common/thread.rs:11
             at src/libstd/sys/unix/thread.rs:81
   7: start_thread
   8: __clone
fatal runtime error: failed to initiate panic, error 5
error: process didn't exit successfully: `/home/nugine/project/rlimit/target/debug/deps/rlimit-5a874300cf08dd30` (signal: 6, SIGABRT: process abort signal)

cgroup-specific limits

Thanks for a handy little library.

I'm currently looking into memory limits, and beyond system RAM and rlimit, on Linux there's also cgroup-specific limits for RAM and CPU. E.g. /sys/fs/cgroup/memory/memory.limit_in_bytes.

I might try to submit a PR, if I have time.

Direct syscalls

Since asm! has been stabilized, I think it's interesting to add support for direct syscalls. It makes a real pure rust binary possible.

This feature will not block rlimit v1.0. It can be added at any time.

Compilation failure on OSX with M1 CPU

Hello! Since upgrading to 0.8, I've had a compilation failure when building on my m1 laptop:

   Compiling rlimit v0.8.0 (/Users/nickm/src/crates/rlimit)
error[E0425]: cannot find value `RLIM_INFINITY` in module `C`
 --> src/unix.rs:7:30
  |
7 | pub const INFINITY: u64 = C::RLIM_INFINITY as u64;
  |                              ^^^^^^^^^^^^^ not found in `C`
error[E0422]: cannot find struct, variant or union type `rlimit` in module `C`
  --> src/unix.rs:23:19
   |
23 |     let rlim = C::rlimit {
   |                   ^^^^^^ not found in `C`
   |
help: consider importing this struct
   |
1  | use libc::rlimit;

... [many similar issues follow] ...

Some errors have detailed explanations: E0422, E0425.
For more information about an error, try `rustc --explain E0422`.
error: could not compile `rlimit` due to 29 previous errors

This problem seems to occur because there is no entry for target_arch="aarch64", target_os="macos" in bindings.rs.

I tried to rectify this by running "scripts/codegen.sh", but got a compilation failure from the C++ code:

./scripts/codegen.cpp:223:52: error: unknown type name 'rlim64_t'; did you mean 'rlim_t'?
    cout << "pub type rlim_t = " << rust_type_name<rlim64_t>() << ";" << endl;
                                                   ^~~~~~~~
                                                   rlim_t

As near as I can tell, my SDK does not have a separate rlim64_t or getrlimit64, so I tried running again with CODEGEN64 disabled.

I'll try writing a PR with the results.

Failed to build because of mismatched types

Hi!

It seems this crate fails to build. To reproduce just create a new "hello world" project, at this dependency to Cargo.toml, and try to build.

Versions:

rlimit v0.1.0
cargo 1.36.0 (c4fcfb725 2019-05-15)
rustc 1.36.0 (a53f9df32 2019-07-03)
OS: Arch Linux
cargo build
   Compiling libc v0.2.58
   Compiling rlimit v0.1.0
error[E0308]: mismatched types
  --> /home/stefano/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.1.0/src/lib.rs:50:45
   |
50 |         let code = unsafe { libc::setrlimit(resource, &mut limit as *mut libc::rlimit) };
   |                                             ^^^^^^^^ expected u32, found i32
help: you can convert an `i32` to `u32` and panic if the converted value wouldn't fit
   |
50 |         let code = unsafe { libc::setrlimit(resource.try_into().unwrap(), &mut limit as *mut libc::rlimit) };
   |                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
  --> /home/stefano/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.1.0/src/lib.rs:61:45
   |
61 |         let code = unsafe { libc::getrlimit(resource, &mut limit as *mut libc::rlimit) };
   |                                             ^^^^^^^^ expected u32, found i32
help: you can convert an `i32` to `u32` and panic if the converted value wouldn't fit
   |
61 |         let code = unsafe { libc::getrlimit(resource.try_into().unwrap(), &mut limit as *mut libc::rlimit) };
   |                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
error: Could not compile `rlimit`.

To learn more, run the command again with --verbose.

rlimit 0.8.1 compilation error on NetBSD

When compiling rlimit 0.8.1 on NetBSD, I see:

error[E0425]: cannot find value `RLIM_INFINITY` in module `C`
 --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/unix.rs:7:30
  |
7 | pub const INFINITY: u64 = C::RLIM_INFINITY as u64;
  |                              ^^^^^^^^^^^^^ not found in `C`
  |
help: consider importing this constant
  |
1 | use libc::RLIM_INFINITY;
  |

error[E0422]: cannot find struct, variant or union type `rlimit` in module `C`
  --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/unix.rs:23:19
   |
23 |     let rlim = C::rlimit {
   |                   ^^^^^^ not found in `C`
   |
help: consider importing this struct
   |
1  | use libc::rlimit;
   |

error[E0425]: cannot find function `setrlimit` in module `C`
  --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/unix.rs:28:27
   |
28 |     let ret = unsafe { C::setrlimit(resource.as_raw() as _, &rlim) };
   |                           ^^^^^^^^^ not found in `C`
   |
help: consider importing one of these items
   |
1  | use crate::setrlimit;
   |
1  | use libc::setrlimit;
   |

error[E0425]: cannot find function `getrlimit` in module `C`
  --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/unix.rs:44:27
   |
44 |     let ret = unsafe { C::getrlimit(resource.as_raw() as _, &mut rlim) };
   |                           ^^^^^^^^^ not found in `C`
   |
help: consider importing one of these items
   |
1  | use crate::getrlimit;
   |
1  | use libc::getrlimit;
   |

error[E0425]: cannot find value `RLIMIT_AS` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:221:15
    |
221 |     AS = 1 => RLIMIT_AS,
    |               ^^^^^^^^^ not found in `C`
    |
help: consider importing this constant
    |
3   | use libc::RLIMIT_AS;
    |

error[E0425]: cannot find value `RLIMIT_CORE` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:226:17
    |
226 |     CORE = 2 => RLIMIT_CORE,
    |                 ^^^^^^^^^^^ not found in `C`
    |
help: consider importing this constant
    |
3   | use libc::RLIMIT_CORE;
    |

error[E0425]: cannot find value `RLIMIT_CPU` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:231:16
    |
231 |     CPU = 3 => RLIMIT_CPU,
    |                ^^^^^^^^^^ not found in `C`
    |
help: consider importing this constant
    |
3   | use libc::RLIMIT_CPU;
    |

error[E0425]: cannot find value `RLIMIT_DATA` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:237:17
    |
237 |     DATA = 4 => RLIMIT_DATA,
    |                 ^^^^^^^^^^^ not found in `C`
    |
help: consider importing this constant
    |
3   | use libc::RLIMIT_DATA;
    |

error[E0425]: cannot find value `RLIMIT_FSIZE` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:242:18
    |
242 |     FSIZE = 5 => RLIMIT_FSIZE,
    |                  ^^^^^^^^^^^^ not found in `C`
    |
help: consider importing this constant
    |
3   | use libc::RLIMIT_FSIZE;
    |

error[E0425]: cannot find value `RLIMIT_KQUEUES` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:246:20
    |
246 |     KQUEUES = 6 => RLIMIT_KQUEUES,
    |                    ^^^^^^^^^^^^^^ not found in `C`

error[E0425]: cannot find value `RLIMIT_LOCKS` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:254:18
    |
254 |     LOCKS = 7 => RLIMIT_LOCKS,
    |                  ^^^^^^^^^^^^ not found in `C`

error[E0425]: cannot find value `RLIMIT_MEMLOCK` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:259:20
    |
259 |     MEMLOCK = 8 => RLIMIT_MEMLOCK,
    |                    ^^^^^^^^^^^^^^ not found in `C`
    |
help: consider importing this constant
    |
3   | use libc::RLIMIT_MEMLOCK;
    |

error[E0425]: cannot find value `RLIMIT_MSGQUEUE` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:265:21
    |
265 |     MSGQUEUE = 9 => RLIMIT_MSGQUEUE,
    |                     ^^^^^^^^^^^^^^^ not found in `C`

error[E0425]: cannot find value `RLIMIT_NICE` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:271:18
    |
271 |     NICE = 10 => RLIMIT_NICE,
    |                  ^^^^^^^^^^^ not found in `C`

error[E0425]: cannot find value `RLIMIT_NOFILE` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:277:20
    |
277 |     NOFILE = 11 => RLIMIT_NOFILE,
    |                    ^^^^^^^^^^^^^ not found in `C`
    |
help: consider importing this constant
    |
3   | use libc::RLIMIT_NOFILE;
    |

error[E0425]: cannot find value `RLIMIT_NOVMON` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:281:20
    |
281 |     NOVMON = 12 => RLIMIT_NOVMON,
    |                    ^^^^^^^^^^^^^ not found in `C`

error[E0425]: cannot find value `RLIMIT_NPROC` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:286:19
    |
286 |     NPROC = 13 => RLIMIT_NPROC,
    |                   ^^^^^^^^^^^^ not found in `C`
    |
help: consider importing this constant
    |
3   | use libc::RLIMIT_NPROC;
    |

error[E0425]: cannot find value `RLIMIT_NPTS` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:290:18
    |
290 |     NPTS = 14 => RLIMIT_NPTS,
    |                  ^^^^^^^^^^^ not found in `C`

error[E0425]: cannot find value `RLIMIT_NTHR` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:297:18
    |
297 |     NTHR = 15 => RLIMIT_NTHR,
    |                  ^^^^^^^^^^^ not found in `C`
    |
help: consider importing this constant
    |
3   | use libc::RLIMIT_NTHR;
    |

error[E0425]: cannot find value `RLIMIT_POSIXLOCKS` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:301:24
    |
301 |     POSIXLOCKS = 16 => RLIMIT_POSIXLOCKS,
    |                        ^^^^^^^^^^^^^^^^^ not found in `C`

error[E0425]: cannot find value `RLIMIT_RSS` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:307:17
    |
307 |     RSS = 17 => RLIMIT_RSS,
    |                 ^^^^^^^^^^ not found in `C`
    |
help: consider importing this constant
    |
3   | use libc::RLIMIT_RSS;
    |

error[E0425]: cannot find value `RLIMIT_RTPRIO` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:313:20
    |
313 |     RTPRIO = 18 => RLIMIT_RTPRIO,
    |                    ^^^^^^^^^^^^^ not found in `C`

error[E0425]: cannot find value `RLIMIT_RTTIME` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:319:20
    |
319 |     RTTIME = 19 => RLIMIT_RTTIME,
    |                    ^^^^^^^^^^^^^ not found in `C`

error[E0425]: cannot find value `RLIMIT_SBSIZE` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:326:20
    |
326 |     SBSIZE = 20 => RLIMIT_SBSIZE,
    |                    ^^^^^^^^^^^^^ not found in `C`
    |
help: consider importing this constant
    |
3   | use libc::RLIMIT_SBSIZE;
    |

error[E0425]: cannot find value `RLIMIT_SIGPENDING` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:332:24
    |
332 |     SIGPENDING = 21 => RLIMIT_SIGPENDING,
    |                        ^^^^^^^^^^^^^^^^^ not found in `C`

error[E0425]: cannot find value `RLIMIT_STACK` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:337:19
    |
337 |     STACK = 22 => RLIMIT_STACK,
    |                   ^^^^^^^^^^^^ not found in `C`
    |
help: consider importing this constant
    |
3   | use libc::RLIMIT_STACK;
    |

error[E0425]: cannot find value `RLIMIT_SWAP` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:342:18
    |
342 |     SWAP = 23 => RLIMIT_SWAP,
    |                  ^^^^^^^^^^^ not found in `C`

error[E0425]: cannot find value `RLIMIT_UMTXP` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:346:19
    |
346 |     UMTXP = 24 => RLIMIT_UMTXP,
    |                   ^^^^^^^^^^^^ not found in `C`

error[E0425]: cannot find value `RLIMIT_VMEM` in module `C`
   --> /home/wiz/.cargo/registry/src/github.com-1ecc6299db9ec823/rlimit-0.8.1/src/resource.rs:350:18
    |
350 |     VMEM = 25 => RLIMIT_VMEM,
    |                  ^^^^^^^^^^^ not found in `C`


getrlimit and setrlimit exist on NetBSD. The man page says to include sys/resource.h.
See https://man.netbsd.org/getrlimit.2

getrlimit64 not defined by musl

Hi :D

I'm getting a build fail on musl system when compiling this crate (as pijul dependency):

error: linking with `cc` failed: exit status: 1
  |
...
  = note: /usr/lib/gcc/x86_64-alpine-linux-musl/13.1.1/../../../../x86_64-alpine-linux-musl/bin/ld: /home/prokop/source/pijul/target/debug/deps/pijul-16f393209566f5b5.2tqz6d1q4sfl10k5.rcgu.o: in function `rlimit::unix::getrlimit':
          /home/prokop/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rlimit-0.6.2/src/unix.rs:141:(.text._ZN6rlimit4unix9getrlimit17h553ee6606f38f36cE+0xa5): undefined reference to `getrlimit64'
          collect2: error: ld returned 1 exit status

I assume this is because unlike glibc 1 2, musl does not define a 64 version of the getrlimit function 3

Changelog?

Could I make a small request? Could you please publish a changelog, especially for breaking changes (e.g., 0.6.2 -> 0.7.0)?

I only ask because I use your crate and benefit from it. 😀

Thanks! 🙏

Test failure on 32bit

https://buildd.debian.org/status/logs.php?pkg=rust-rlimit&ver=0.7.0-1

test rlim::rlim_value ... FAILED

failures:

---- rlim::rlim_value stdout ----
thread 'rlim::rlim_value' panicked at 'assertion failed: `(left == right)`
  left: `"4294967295\n4294967295\n4294967295\n"`,
 right: `"18446744073709551615\n18446744073709551615\n18446744073709551615\n"`', tests/it/rlim.rs:45:5
stack backtrace:
   0: rust_begin_unwind
             at /usr/src/rustc-1.57.0/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /usr/src/rustc-1.57.0/library/core/src/panicking.rs:100:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
             at /usr/src/rustc-1.57.0/library/core/src/panicking.rs:138:5
   4: it::rlim::rlim_value
             at /usr/share/cargo/registry/rlimit-0.7.0/tests/it/rlim.rs:45:5
   5: it::rlim::rlim_value::{{closure}}
             at /usr/share/cargo/registry/rlimit-0.7.0/tests/it/rlim.rs:29:1
   6: core::ops::function::FnOnce::call_once
             at /usr/src/rustc-1.57.0/library/core/src/ops/function.rs:227:5
   7: core::ops::function::FnOnce::call_once
             at /usr/src/rustc-1.57.0/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    rlim::rlim_value

test result: FAILED. 4 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.35s

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.