Follow

linux fun, ulimits 

Linux tip: if you want to run a command that might get out of hand, you can use `prlimit` to set process-specific limits to keep it in line.

So if you're, say, trying to build a Verilog project that might have some exponential nesting if you do it wrong, instead of running `make dangerous.vvp`, you can run:

prlimit --as=10000000000 make dangerous.vvp

Then when it gets greedy and tries to address more than 10GB(ish) of memory, malloc will refuse and it'll crash instead of bogging your system to a standstill until you manage to get a kill command thrown at it.

There are plenty of limits to be had, `man prlimit` will tell you about them. Heads up though, while --as (address-space) is a rather blunt weapon, the more reasonable --rss limit is not honored on many systems, including mine, apparently. prlimit doesn't warn you about this, but the ulimit section of `man bash` does.

Also if you don't know what's going on here, I'm skipping a lot of details - happy to elaborate if you're curious!

· · Web · 1 · 1 · 2

linux fun, ulimits 

Why are prlimit's memory sizes in bytes if ulimit's sizes are in kilobytes? I don't know! But testing bears out that that is the case.

Also, like, yeah this is a mess, but that's the whole point of this project, so it fits right in 😄

For extra wonkiness, why not bake the prlimit right into your makefile? You know I did!

Sign in to participate in the conversation
Cybrespace

cybrespace: the social hub of the information superhighway jack in to the mastodon fediverse today and surf the dataflow through our cybrepunk, slightly glitchy web portal support us on patreon or liberapay!