Oddly enough, I was improving the shining hour in a hospital waiting room
earlier today by reading the camel book Chapter 23 Security.  There is a
good discussion of this whole topic, bearing very exactly on what Luinrandir
is trying to do.

L, if you haven't already got this book "Programming Perl" by Wall et al,
published by O'Reilly, you should!  If you're a total beginner, first read
the llama book, O'Reilly again, "Learning Perl" by Schwartz, who
occasionally posts to this list as "Merlyn".

Neither of these books are ever more than 6 feet (2m!) away from my desk,
except when I'm reading them in a more comfortable chair...

Rgds, GStC.


-----Original Message-----
From: Ovid [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 14, 2005 2:47 PM
To: Luinrandir Hernsen; beginners-cgi@perl.org
Subject: Re: Read Write to file .. need help

<snip/>

Reading and writing files from CGI scripts can be tricky due to "race
conditions".  A race condition occurs when more than one process is trying
to do something but the data corruption can occur if they do those things in
the wrong order.  So let us say you want to

1. open a file
2. flock it
3. write to it
4. close it

Now let's say another process tries to read that file but does so after the
first process executes step one and before it executes step two. 
The second process will be trying to read an apparently empty file. 
"sysopen' actually allows you to open and lock the file at the same time,
but this is not supported on all systems.

For a clean way of handling this by using what are known as "semaphore"
files, read "Resource locking with semaphore files"
(http://interglacial.com/~sburke/tpj/as_html/tpj23.html)

Cheers,
Ovid


=====
Silence is Evil
http://users.easystreet.com/ovid/philosophy/decency.html
Ovid                       http://www.perlmonks.org/index.pl?node_id=17000
Web Programming with Perl  http://users.easystreet.com/ovid/cgi_course/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to