develooper Front page | perl.perl5.porters | Postings from December 2008

Re: [perl #1154] [RESOLVED] -pi doesn't sanely handle write errors

Morty Abzug
December 14, 2008 06:03
Re: [perl #1154] [RESOLVED] -pi doesn't sanely handle write errors
Message ID:
When I attempted to verify the fix using bleadperl, the bug still
seemed to be there.  I didn't get an error, and the return status was
0.  Am I missing something?

Methodology used to install bleadperl:

  mkdir ~/bleadperl ~/localperl &&
  cd ~/bleadperl &&
  rsync -avz rsync:// . &&
  ./Configure -des -Dusedevel -Dprefix=$HOME/localperl &&
  make test &&
  make install; finished

Methodology used to test:


# script to demo problem of perl not detecting write errors with -pi
# requires root on a linux system

MKFS_ARGS="-t ext2"
MOUNT_ARGS="-o loop"

echo Perl version:
$PERL -v

cd / &&
mkdir -p $IMG_DIR &&
dd if=$SOURCE of=$IMG bs=$BS count=$IMG_SIZE &&
mkfs $MKFS_ARGS $IMG </dev/null &&
dd if=$SOURCE of=$FILE bs=$BS count=$FILE_SIZE &&
echo before running perl: && df -k . && ls -l bar* &&
echo Running perl. . . &&
$PERL -pi~ -e 1 $FILE

echo Done. Status is: $? && df -k . && ls -l bar*

# clean up regardless of status
cd /; umount $MOUNTPOINT; rm $IMG

Output of script above:

Perl version:

This is perl, v5.11.0 DEVEL35082 built for i686-linux
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2008, Larry Wall

Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5 source

Complete documentation for Perl, including FAQ lists, should be found
this system using "man perl" or "perldoc perl".  If you have access to
Internet, point your browser at, the Perl Home

1440+0 records in
1440+0 records out
1474560 bytes (1.5 MB) copied, 0.00894997 s, 165 MB/s
mke2fs 1.40.8 (13-Mar-2008)
/root/floppy.img is not a block special device.
Proceed anyway? (y,n) Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
184 inodes, 1440 blocks
72 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=1572864
1 block group
8192 blocks per group, 8192 fragments per group
184 inodes per group

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
900+0 records in
900+0 records out
921600 bytes (922 kB) copied, 0.00389722 s, 236 MB/s
before running perl:
Filesystem           1K-blocks      Used Available Use% Mounted on
/root/floppy.img          1412       924       416  69% /mnt
-rw-r--r-- 1 root root 921600 2008-12-14 00:27 bar
Running perl. . .
Done. Status is: 0
Filesystem           1K-blocks      Used Available Use% Mounted on
/root/floppy.img          1412      1411         0 100% /mnt
-rw-r--r-- 1 root root 495616 2008-12-14 00:27 bar
-rw-r--r-- 1 root root 921600 2008-12-14 00:27 bar~

- Morty (remotely) Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About