in reply to <rant>CPAN modules failing to check for write errors</rant>
Printing to a file handle with insufficient disk space does not produce a failure, at least not on my system. Rather, the failure happens when you call close(). A lot of people don't check the return value of close() (including me), but maybe they should.
To test this, I created a 1 MB loopback filesystem and wrote a bit of Perl to write a lot of data to it:
$ dd if=/dev/zero of=./test_small_lo count=1 bs=1M 1+0 records in 1+0 records out $ sudo /sbin/losetup /dev/loop0 ./test_small_lo $ sudo /sbin/mkfs.ext2 /dev/loop0 [ snip output ] $ sudo mount /dev/loop0 /mnt/data $ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/loop0 1003 13 939 2% /mnt/data [ snip other mounted file systems ] $ cd /mnt/data $ sudo touch test_file $ sudo chmod 666 test_file # So I don't have to run code below as root $ perl -e ' > open( FH, ">", "test_file" ) or die $!; > for( 0 .. 10_000_000 ) { print FH 1 or die $! } > close(FH) or die $! ' No space left on device at -e line 3.
I honestly don't see the point in checking print()'s return value. It puts in more code that will only happen for such extremely rare occasions that you can simply discount them.
Update: See my reply to adrianh below.
----
send money to your kernel via the boot loader.. This and more wisdom available from Markov Hardburn.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: <rant>CPAN modules failing to check for write errors</rant>
by adrianh (Chancellor) on Jun 01, 2004 at 16:59 UTC | |
by hardburn (Abbot) on Jun 01, 2004 at 17:40 UTC |