PolettiX:~# dd if=/dev/zero of=testfile bs=1024 count=1024 1024+0 records in 1024+0 records out 1048576 bytes transferred in 0.019164 seconds (54715967 bytes/sec) PolettiX:~# PolettiX:~# PolettiX:~# mkfs.ext2 testfile mke2fs 1.37 (21-Mar-2005) testfile is not a block special device. Proceed anyway? (y,n) y Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) 128 inodes, 1024 blocks 51 blocks (4.98%) reserved for the super user First data block=1 1 block group 8192 blocks per group, 8192 fragments per group 128 inodes per group Writing inode tables: done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 27 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. PolettiX:~# PolettiX:~# PolettiX:~# mount testfile -o loop /mnt
Now you have a filesystem that will be easy to fill up:
#!/usr/bin/perl use strict; use warnings; use Fatal qw( open close ); chdir '/mnt'; { open my $fh, '>', 'prova.dat'; print {$fh} "ciao\n" for 1 .. 1000000; # close $fh; } print {*STDERR} "should be closed here!\n";
In my system, the final string on STDERR gets printed when the close above is commented; uncommenting the close triggers the fatal error:
Can't close(GLOB(0x814cd4c)): No space left on device at (eval 2) line + 3 main::__ANON__('GLOB(0x814cd4c)') called at ./prova.pl line 13
Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
In reply to Re: How do I make the garbage collector throw an exception when it fails to auto-close a filehandle?
by polettix
in thread How do I make the garbage collector throw an exception when it fails to auto-close a filehandle?
by Aristotle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |