[Melbourne-pm] An intermittent problem with open for append

Tim Hogard thogard at abnormal.com
Tue May 27 22:54:09 PDT 2008


Hi,

I've got a CGI program that has a problem every once in a while.

The problem code looks like:

open OUT,">>/home/foo/que/$ip" || push @error, "Cant save details";
print OUT "$ip:t:date=",scalar localtime,"\n";
... then it prints to OUT all the rest of ${ENV} and CGI vars.

Sometimes apache will record 2 hits on the page (a double click?)
and most of the time I get two sets of all the data however sometimes
while running perl 5.8.8 I only get the first or second sometimes.
This never happens with perl 5.005_02.

Can anyone explain why perl 5.005 works yet 5.8.8 doesn't?
I was under the impresson that the ">>" means tell the OS to
open in append mode, any data written should go in the file
and not just end up lost.

This is perl, v5.8.8 built for sun4-solaris
This is perl, version 5.005_02 built for sun4-solaris
Solaris 5.5.1 is the OS.

I'm not even which direction to try to debug this problem is its
it only happens once in a million times or so.

I guess I could write a program to produce 3 children and have each of them
open a file and append their PID and hunt for errors or maybe even trace
that the append flag is in fact on (is there an easy way to get that info?)
or maybe its a singal problem where its getting an odd signal.

Any ideas?

-tim



More information about the Melbourne-pm mailing list