Help for this page

Select Code to Download


  1. or download this
    perl -MBSD::Resource -le'setrlimit(RLIMIT_NPROC,20,50);
      system qq(echo 1);' # hangs, fork fails with EAGAIN
    perl -MBSD::Resource -le'setrlimit(RLIMIT_NPROC,20,20);
      system qq(echo 1);' # also hangs
    
  2. or download this
    perl -MBSD::Resource -le'setrlimit(RLIMIT_NPROC,20,10);
      system qq(echo 1);' # succeeds
    ...
    perl -MBSD::Resource -le'setrlimit(RLIMIT_NPROC,2,1);
      for(1..10){if(fork==0){print"child $_";sleep 1;exit}};
      waitpid(-1,0)' # succeeds, prints "child 1".."child 10"