Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - setrlimit behaviour: (2 Items)
   
setrlimit behaviour  
I've never used this function, but I had a question about its use in restricting a launched program's memory allocation.
  In reading the docs (http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/lib_ref/s/setrlimit.html ), I think that it 
would work like this:

Controlling program calls setrlimit to lower RLIMIT_DATA
Controller then launches child process
Child process inherits new lower rlimit
Controller calls setrlimit again to bump limit back to normal.

I have three questions:

  1.  Is my interpretation of setrlimit the proper way to spawn a child process with restricted memory limits?
  2.  What happens if the controlling app lowers the RLIMIT_DATA below what memory it's actually using?  My 
interpretation is that the next heap alloc through brk() will fail, which means that you better not do this if you're 
multi-threaded unless you can guarantee no other threads will alloc memory.
  3.  Is there any way to inject an rlimit into an already running process?

Attachment: HTML sf-attachment-mime3930 1.57 KB
Re: setrlimit behaviour  
The gear in the kernel appears to be in place to set limits on a given process, what's missing is the extension to libc,
 something like prlimit() on linux.