My entry in the "Least Used Software EVAH" competition

Posted: Wed, 15 October 2014 | permalink | 2 Comments

For some reason, I seem to end up writing software for very esoteric use-cases. Today, though, I think I’ve outdone myself: I sat down and wrote a Ruby library to get and set process resource limits – those things that nobody ever thinks about except when they run out of file descriptors.

I didn’t even have a direct need for it. Recently I was grovelling through the EventMachine codebase, looking at the filehandle limit code, and noticed that the pure-ruby implementation didn’t manipulate filehandle limits. I considered adding it, then realised that there wasn’t a library available to do it. Since I haven’t berked around with FFI for a while, I decided to write rlimit. Now to find the time to write that patch for EventMachine…

Since I doubt there are many people who have a burning need to manipulate rlimits in Ruby, this gem will no doubt sit quiet and undisturbed in the dark, dusty corners of rubygems.org. However, for the three people on earth who find this useful: you’re welcome.


2 Comments

From: Christian Neukirchen
2014-10-22 06:51

So, what’s the difference to the core Process.setrlimit function?

Process.setrlimit('NOFILE', 1)
File.open("/etc/passwd")

From: Matt Palmer
2014-10-25 08:11

Hi Christian,

So, what’s the difference to the core Process.setrlimit function?

Uhm… I know my gem exists? (grin) When I was researching the original EM bug that led down this road, I found no indication that Process.{get,set}rlimit existed.

One thing that the rlimit gem does that I don’t think the built-in code does is allow you to determine at runtime whether a given limit is available.

Post a comment

All comments are held for moderation; markdown formatting accepted.

This is a honeypot form. Do not use this form unless you want to get your IP address blacklisted. Use the second form below for comments.
Name: (required)
E-mail: (required, not published)
Website: (optional)
Name: (required)
E-mail: (required, not published)
Website: (optional)