[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2215
  • Last Modified:

how do you set ulimit -n 5000 in perl.

How do I set "ulimit -n 5000" in perl so that it
takes affect for child processes.
I tried `ulimit -n 5000` (backtics) but a
subsequent `ulimit -n` showed the value
set back to the default.      
0
ggoldsc
Asked:
ggoldsc
1 Solution
 
monasCommented:
install BSD::Resource

then

use BSD::Resource;

$LIM = get_rlimits();
$lim = $LIM{RLIMIT_NOFILE};
($soft, $hard) = getrlimit($lim);
setrlimit($lim, 9000, $hard);

add error checking everythere.
Perl doesn't have direct interface to ulimit
0
 
BRI70Commented:
Another option is to set your ulimit prior to running your perl program.  Make sure you use the #!/usr/bin/perl shebang line and run perl so that it does not spawn a new shell like this:
ulimit -n 5000; ./my_perl_script_with_shebang_line.pl

Open in new window

0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now