<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1013020" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1013020</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/file-locking#comment-1078265</link>
    <description> &lt;p&gt;top&lt;/p&gt;
&lt;p&gt;k, i ran across this bit of data:&lt;/p&gt;
&lt;blockquote class=&quot;bb-quote-body&quot;&gt;&lt;p&gt;Quote:&lt;br /&gt;
CGI processes on a Unix web server can run simultaneously, and if two scripts try to open and write the same file at the same time, the file may be erased, and you&#039;ll lose all of your data. To prevent this, we&#039;ve used flock(OUTF,2) in the survey.cgi to exclusively lock the survey file while we are writing to it. (The 2 means exclusive lock.) The lock will be released when your script finishes running, allowing the next CGI to access the file. This is only effective if all of the CGIs that read and write to that file also use flock; without flock, the CGI will ignore the locks of any other process and  open/write/erase the file. Since flock may force the CGI to wait for another CGI to finish writing to a file, you should also reset the file pointer, using the seek function.&lt;br /&gt;
...If you were reading the file instead of writing to it, you&#039;d want to do a seek(FILEHANDLE,0,0) to reset the pointer to the beginning of the file.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;that partially answers some of my questions, correct me if im wrong.  a file that has potential to be accessed from other processes should ALWAYS be flocked, and the file pointer needs to be set to 0 using seek but only if the file was being read from, not written to.  correct?&lt;/p&gt;
&lt;p&gt;also someone suggested to me that file locking is not a concern on windows machines as the operating system does this for you. any truth to that?&lt;/p&gt;
 </description>
     <pubDate>Fri, 16 Feb 2001 09:11:51 +0000</pubDate>
 <dc:creator>ROB</dc:creator>
 <guid isPermaLink="false">comment 1078265 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/file-locking#comment-1075563</link>
    <description> &lt;p&gt;open(HEH, $file);&lt;br /&gt;
flock(HEH, 2);&lt;br /&gt;
print HEH $_[2];&lt;br /&gt;
flock(HEH, 8);&lt;br /&gt;
close(HEH);&lt;/p&gt;
&lt;p&gt;I think that works. I&#039;m pretty sure you only have to flock when printing to a file, but not when opening one up.&lt;/p&gt;
 </description>
     <pubDate>Tue, 12 Dec 2000 04:36:23 +0000</pubDate>
 <dc:creator>Vorm</dc:creator>
 <guid isPermaLink="false">comment 1075563 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
