Ewerta Lent has asked for the wisdom of the Perl Monks concerning the following question:

Greetings,
I am using PERL to launch a precompiled C application via "system" and would like to know if there is any way to alter system limits on the coredumpsize to allow for this C application to dump core when it crashes for debugging purposes. I checked BSD::Resources but as far as I can tell its purposes are for merely checking, not setting this limit. I was wondering if there is another module that handles this, or a built-in PERL subroutine/environmental variable.
Thanks in advance,
-E

Replies are listed 'Best First'.
Re: PERL coredump limit
by Fletch (Bishop) on Aug 03, 2004 at 17:03 UTC

    Erm, what do you think BSD::Resource's setrlimit() routine's for?

    setrlimit( BSD::Resource::RLIMIT_CORE(), 0, 0 ) or warn "Can't set core file size limit to 0: $!\n";

      Note that you may well find that you can only increase the core file size limit if you're running as root.

      Hugo

        Right, a non-root user can only lower the hard limit (rlim_max) and/or set the soft (rlim_cur) anywhere between 0 and the current hard limit. But that's going to be the case whether you use BSD::Resource or the shell's ulimit builtin.

Re: PERL coredump limit
by gellyfish (Monsignor) on Aug 03, 2004 at 16:59 UTC

    On most unix-like systems you will be able to set the core size with ulimit -c $size I guess you could wrap a call to setrlimit(3) with Inline if you don't want to use system() to call the command.

    /J\

Re: PERL coredump limit
by thor (Priest) on Aug 03, 2004 at 16:58 UTC
    Generally, one does this with limit or ulimit, depending on one's shell. Consult the man pages for those commands to find out the details.

    thor

    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    With all of us waiting, your kingdom will come