My responses below. On Fri, Jul 8, 2011 at 2:55 PM, Michal Petrucha <michal.petru...@ksp.sk> wrote: > On Fri, Jul 08, 2011 at 02:43:11PM +0100, Cal Leeming [Simplicity Media Ltd] > wrote: >> Sorry, I should have given a bit more detail. >> >> Using ulimit is going to be an issue as it relies on the host allowing >> users to modify their ulimit (some aren't allowed). It also then >> applies that rule to any other processes within that user, which is >> bad as different processes may need different limits. > > My bash(1) man page says the following: > "Provides control over the resources available to the shell and to > processes started by it, on systems that allow such control." > > Also, setrlimit(3) states this: > "A child process created via fork(2) inherits its parent's resource > limits. Resource limits are preserved across execve(2)."
Ah, I found setrlimit earlier, but I somehow missed the section about fork() inheriting the parent's resource limits (guess I skimmed through the man too quickly), so many thanks for clarifying this. > > Which means, if you set a ulimit in a process, only the process itself > and its children are affected. At least that's how I understand it. > > My understanding is backed by the fact that online judges used in ACM > ICPC-like contest use setrlimit in their sandboxes to limit the memory > for submitted solutions. (-; Ack. > >> I have seen other examples in the past of binaries being wrapped, >> which then applied a memory limit, but I can't for the life of me >> remember what it was called. :( > > Just running it as > bash -c 'ulimit -S <set your limits here>; command' should be enough. > Or if you want, you can create your own wrapper in C which calls > setrlimit and then execs the binary. Although I'm sure both methods would work, would you recommend any particular preference? (as my preference is merely on the fact that having a wrapper seems a lot cleaner). I guess the custom binary I was trying to think of earlier used the setrlimit/fork method mentioned above. > > Michal > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.