Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change getrlimit and setrlimit to use rlim_t directly. #1668

Merged
merged 1 commit into from
Mar 14, 2022
Merged

Change getrlimit and setrlimit to use rlim_t directly. #1668

merged 1 commit into from
Mar 14, 2022

Conversation

Arnavion
Copy link
Contributor

@Arnavion Arnavion commented Mar 5, 2022

Fixes #1666

@Arnavion Arnavion changed the title Change getlimit and setlimit to use rlim_t directly. Change getrlimit and setrlimit to use rlim_t directly. Mar 5, 2022
Copy link
Member

@asomers asomers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @rtzoeller do you have any thoughts on this one?

@rtzoeller
Copy link
Collaborator

@Arnavion can you add back a reference to RLIM_INFINITY in the documentation for both the getter and setter? Even if nix isn't handling it, I'd expect that users might need to.

We can paraphrase from this part of the documentation:

If a call to getrlimit() returns RLIM_INFINITY for a resource, it means the implementation shall not enforce limits on that resource. Specifying RLIM_INFINITY as any resource limit value on a successful call to setrlimit() shall inhibit enforcement of that resource limit.

Otherwise the changes look good to me.

@Arnavion
Copy link
Contributor Author

Arnavion commented Mar 6, 2022

Done.

/// > Note: for some os (linux_gnu), setting hard_limit to `RLIM_INFINITY` can
/// > results `EPERM` Error. So you will need to set the number explicitly.
/// The special value `RLIM_INFINITY` indicates that no limit will be
/// enforced. For some OSes (linux_gnu), setting the hard limit to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that Linux returns EPERM because the user tried to set RLIM_INFINITY specifically. Rather, I think that happens because the user tries to raise the limit. That's disallowed on every OS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I wasn't sure why the comment was initially worded the way it was. I can fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, is there a point in fixing it? It would just be duplicating the spec, that's already linked as a reference. Should I just delete that sentence?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asomers Ping.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing it should be ok, but we shouldn't leave the wrong explanation in place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

CHANGELOG.md Outdated
@@ -54,6 +54,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
(#[1665](/~https://github.com/nix-rust/nix/pull/1665))
- Implemented `Read` and `Write` for `&PtyMaster`
(#[1664](/~https://github.com/nix-rust/nix/pull/1664))
- Changed `getrlimit` and `setrlimit` to use `rlim_t` directly
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go in the "Changed" section, rather than "Added".

If you squash and rebase, this LGTM.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

@asomers asomers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

bors bot added a commit that referenced this pull request Mar 14, 2022
1668: Change getrlimit and setrlimit to use rlim_t directly. r=asomers a=Arnavion

Fixes #1666

Co-authored-by: Arnavion <me@arnavion.dev>
@bors
Copy link
Contributor

bors bot commented Mar 14, 2022

Build failed:

@rtzoeller
Copy link
Collaborator

bors retry

@bors bors bot merged commit 9e63cb7 into nix-rust:master Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nix::sys::resource::getrlimit doesn't actually return None
3 participants