简体   繁体   English

您如何防止perl制作转储文件?

[英]How do you prevent perl from making a dump file?

Currently I am running several scripts which are in a experimental testing stage. 目前,我正在运行几个处于实验测试阶段的脚本。 Unfortunately they crash on occasion and generate large "core-perl-11-544-546-27320-1xxxxxxx" perl core dump files. 不幸的是,它们有时会崩溃并生成大型的“ core-perl-11-544-546-27320-1xxxxxxx” perl核心转储文件。

I want to ensure that if in the future these files crash again, they do not generate perl dump files, or the files size of the dump is limited. 我想确保如果将来这些文件再次崩溃,它们不会生成perl转储文件,或者转储的文件大小受到限制。

Right now there are some scripts checking for Perl core dump files and removing them if they are greater than a set size, but this is an obvious band-aid on a broken knee. 现在,有一些脚本检查Perl核心转储文件,如果它们大于设置的大小,则将其删除,但这显然是一个临时的创可贴。

How might I go about limiting the size of the perl dump file, or preventing one from being made? 我应该如何限制perl转储文件的大小,或者防止生成一个文件?

To prevent the creation of a core dump file from within the perl script, you can use (procedure stolen from How do I set a ulimit from inside a Perl script that applies to its children? ): 要防止从perl脚本内创建核心转储文件,可以使用(从如何从适用于其子级的Perl脚本内部设置ulimit偷来的程序):

require 'syscall.ph';
require 'sys/resource.ph';
$rstruct = pack "L!L!",0,&RLIM_INFINITY;
syscall(&SYS_setrlimit,&RLIMIT_CORE,$rstruct);

To limit dumps to a certain size, change the 0 above to the desired size. 要将转储限制为特定大小,请将上面的0更改为所需大小。

wouldn't 不会

use BSD::Resource; 使用BSD :: Resource; setrlimit(RLIMIT_CORE, 0, 0); setrlimit(RLIMIT_CORE,0,0);

be simpler? 更简单?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM