[egartz@localhost fullment_programs]$ ulimit -f 10 [egartz@localhost fullment_programs]$ ./lots_of_print.pl File size limit exceeded [egartz@localhost fullment_programs]$
#!/usr/local/bin/perl -w
use strict;
open (LARGE_FILE, ">large_file.txt");
for ( 1 .. 10000){
print LARGE_FILE "dummy line...dummy line...dummy line...dummy line...dummy line...dummy line...dummy line...\n" or print STDERR "i caught the error!\n";
}
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
See the full manpage.
--
John.
Take a look at the manpage for setrlimit (which ulimit uses to implement it's functionality). On my system this says
RLIMIT_FSIZE
The maximum size of files that the process may create. Attempts to extend a file beyond this limit result in delivery of a SIGXFSZ signal. By default, this signal terminates a process, but a process can catch this signal instead, in which case the relevant system call (e.g., write(), truncate()) fails with the error EFBIG.
So in order to prevent your program from terminating you need to catch the SIGXFSZ signal, either by setting local $SIG{XFSZ}=IGNORE or by doing something more fancy, aka
local $SIG{XFSZ}=sub { print STDERR "Caught SIGXFSZ" };
perlmonks.org content © perlmonks.org and egunnar, jmcnamara, merlyn, tirwhan
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03