Add LibC.setrlimit/LibC.getrlimit to all linux/bsd platforms#10569
Add LibC.setrlimit/LibC.getrlimit to all linux/bsd platforms#10569carlhoerberg wants to merge 11 commits intocrystal-lang:masterfrom
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.
If this is an int, can we add a type restriction?
There was a problem hiding this comment.
| def self.file_descriptor_limit=(limit) | |
| def self.file_descriptor_limit=(limit : UInt32) |
There was a problem hiding this comment.
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.
In any case, the same type should be applied as return type of the getter method.
There was a problem hiding this comment.
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.