From: John Wells Date: 2008-01-02T11:59:51+09:00 Subject: Re: Modifying parent shell's attributes? On 12/13/07, Austin Ziegler wrote: > On 12/13/07, John Wells wrote: > > I asked this on the rails list, but received no traction. Since it's > > more of a ruby question anyway, thought I'd give it a shot here. > > > > I have a problem with one of my rake tasks. It loads a very large yaml > > file into the db, but because of the default limitation on stack size > > in the Linux shell, the task craps out. Executing "ulimit -s 16384" > > fixes the issue, and the task completes just fine. > > > > What I'd like to do within my task is this (in ruby-ish pseudo): > > > > if on_linux? > > set_stack_of_running_shell_via_ulimit 16384 > > end > > > > Is there any way to do this? Can I modify the attributes of the shell > > that is running me? > > Check out the Process class; specifically getrlimit and setrlimit. It > won't change the shell, but it will change Ruby. Following up a bit late on this, but this doesn't solve my problem. for some reason. I have tried: Process.setrlimit Process::RLIMIT_STACK, Process::RLIM_INFINITY, Process::RLIM_INFINITY Process.setrlimit Process::RLIMIT_STACK, 0, Process::RLIM_INFINITY Is this the proper usage? It still craps out with same error, but setting ulimit in the calling shell to 16000 works just fine. Thanks! John