mogrify may cause data loss
Posted: 2008-12-19T08:34:43-07:00
Hi!
From http://bugs.debian.org/324203 and http://bugs.debian.org/358407, we can see that a file can get lost/corrupted if interrupted when mogrify is running.
A test script that shows this behavior:
(maybe you want to echo 2 > /proc/sys/vm/overcommit_memory on a Linux system, before testing it).
Can mogrify be modified to work atomically, please?
Thank you!
From http://bugs.debian.org/324203 and http://bugs.debian.org/358407, we can see that a file can get lost/corrupted if interrupted when mogrify is running.
A test script that shows this behavior:
Code: Select all
#!/usr/bin/perl
use Time::HiRes qw( usleep );
use POSIX;
$file = "file.jpg";
$size=(stat($file))[7];
$i=0;
while( $size > 0 && $i < 100000 ){
if($p=fork) {
usleep(rand(10000));
for($i=0;$i<10000;$i++) {
kill(15,$p);
}
} else {
usleep(rand(10000));
system("mogrify -scale 1024 $file") or die "mog";
exit;
}
$i++;
}
print "Done $i $size.\n";
Can mogrify be modified to work atomically, please?
Thank you!