How do I set a ulimit from inside a Perl script that applies to its children?

后端 未结 4 2025
花落未央
花落未央 2021-01-02 16:00

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 r

4条回答
  •  萌比男神i
    2021-01-02 16:26

    You can always wrap your perl in a little shell script:

    #!/bin/sh -- # --*-Perl-*--
    ulimit -n 2048
    exec /usr/bin/perl -x -S $0 ${1+"$@"}
    #!/usr/bin/perl
    #line 6
    
    use strict;
    
    # etc, etc....
    

    It's ugly, and obviously, script start up time will be slightly longer.

提交回复
热议问题