title: How do I set a ulimit from inside a Perl script that applies to its children?
body: <p>I have a Perl script that does various installation steps to set up a development box for our company. It runs various shell scripts, some of which crash due to lower than required <code>ulimit</code>s (specifically, stack size <code>-s</code> in my case).</p>
  
  <p>Therefore, I'd like to set a <code>ulimit</code> that would apply to all scripts (<code>children</code>) started from within my main Perl one, but I am not sure how to achieve that - any attempts at calling ulimit from within the script only set it on that specific child shell, which immediately exits.</p>
  
  <p>I am aware that I can call <code>ulimit</code> before I run the Perl script or use <code>/etc/security/limits.conf</code> but I don't want the user to know any of this - they should only know how to run the script, which should take care of all of that for them.</p>
  
  <p>I can also run <code>ulimit</code> every time I run a command, like this <code>ulimit -s BLA; ./cmd</code> but I don't want to duplicate this every time and I feel like there's a better, cleaner solution out there.</p>
  
  <p>Another crazy "workaround" is to make a wrapper script called BLA.sh which would set ulimit and call BLA.pl, but again, it's a hack in my mind and now I'd have 2 scripts (I could even make BLA.pl call itself with "ulimit -s BLA; ./BLA.pl --foo" and act differently based on whether it sees --foo or not but that's even hackier than before).</p>
  
  <p>Finally, apparently I could install BSD::Resource but I'd like to avoid using external dependencies.</p>
  
  <p><strong>So what is <em>THE</em> way to set the ulimit from within a Perl script and make it apply to all children?</strong></p>
  
  <p>Thank you.</p>