-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add LibC.setrlimit/LibC.getrlimit to all linux/bsd platforms #10569
base: master
Are you sure you want to change the base?
Conversation
a3f4946
to
23f910f
Compare
23f910f
to
81fe886
Compare
What's the reason for this? Where are these functions used? It appears |
Also please remember to always open an issue before a PR in order to discuss things. Or at least provide a description in the PR. |
We use it here: https://github.com/cloudamqp/avalanchemq/blob/6560de727cdb210e4523333a0577442268c0ae45/src/stdlib/resource.cr#L74 to implement |
I think we should add a way to use Using For example Ruby has it in the
That way you can use it through the standard library, and we make sure it's there in all the platforms we support. |
The C bindings coming with the standard library are an implementation detail, they're not part of the public API. There shouldn't be any C bindings that are not required for stdlib itself. But I agree with @asterite that it might be a good idea to actually add support for accessing file descriptor limits to stdlib directly. |
That said, I wouldn't mind merging this. It doesn't hurt anymore. More so if we later plan on using those bindings. |
@carlhoerberg Would you be interested in incorporating the |
ok, can do |
I have no idea about Windows support though.. just wrap the spec in |
src/system.cr
Outdated
# ``` | ||
# System.file_descriptor_limit = 4096 | ||
# ``` | ||
def self.file_descriptor_limit=(limit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is an int, can we add a type restriction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def self.file_descriptor_limit=(limit) | |
def self.file_descriptor_limit=(limit : UInt32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UInt32
technically doesn't cut it the value is 64 bits wide on 64-bit platforms. In practice, this shouldn't be relevant, though. So we can perhaps stay with 32 bits. But maybe it should be signed instead? We try to avoid unsigned integer types in stdlib APIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case, the same type should be applied as return type of the getter method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking just Int
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the param type restriction, that would be good. But what about the return type?
For the specs, you can just use Additionally, |
Fixed your comments, settled for Int32, I don't think it's technically possible to have 2 billion FDs anyway 🤞 Regarding OS X there seems to be some issues with subprocesses and the FD limit inheritance, doesn't seem to work the same way as in Linux.. Try to dig deeper into it. |
No description provided.