title: set stack size for threads using setrlimit
body: <p>I'm using a library which creates a pthread using the default stack size of 8MB.  Is it possible to programatically reduce the stack size of the thread the library creates?  I tried using <code>setrlimit(RLIMIT_STACK...)</code> inside my <code>main()</code> function, but that doesn't seem to have any effect.  <code>ulimit -s</code> seems to do the job, but I don't want to set the stack size before my program is executed.  </p>
  
  <p>Any ideas what I can do?  Thanks</p>
  
  <p>Update 1:
  Seems like I'm going to give up on being able to set the stack size using <code>setrlimit(RLIMIT_STACK,...).</code>  I checked the resident memory and found it's a lot less than the virtual memory.  That's a good enough reason for me to give up on trying to limit the stack size.   </p>