<?xml version="1.0" encoding="windows-1252"?>
<node id="1008654" title="Re: flock on Windows : process killed while in critical region" created="2012-12-13 07:27:29" updated="2012-12-13 07:27:29">
<type id="11">
note</type>
<author id="171588">
BrowserUk</author>
<data>
<field name="doctext">
&lt;blockquote&gt;&lt;i&gt;
 Now I wonder: Could there be cases, where a process gets killed while being in the critical region, BUT the lock is not being released (and therefore all other processes would be locked out forever)?
&lt;/i&gt;&lt;/blockquote&gt;

&lt;p&gt;In a nutshell: No, that cannot happen.

&lt;p&gt;However, if a process terminates whilst holding a lock, it may be some time before the OS gets around to releasing the lock -- dependent upon the availability of suitable system resources -- so attempts to acquire the lock should be programmed to retry, &lt;i&gt;without tight loop polling&lt;/i&gt;, as a tight polling loop can itself be the cause of the unavailability of those system resources.

&lt;p&gt;(For more info, see the "Remarks" under [http://msdn.microsoft.com/en-us/library/windows/desktop/aa365203(v=vs.85).aspx|LockFile(Ex)()], which is the system call that underlies perl's emulation of flock() on Windows.)

&lt;div class="pmsig"&gt;&lt;div class="pmsig-171588"&gt;
&lt;hr /&gt;
&lt;font size=1 &gt;
&lt;div&gt;With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'&lt;/div&gt;
&lt;div&gt;Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.&lt;/div&gt;
&lt;div&gt;"Science is about questioning the status quo. Questioning authority". &lt;/div&gt;
&lt;div&gt;In the absence of evidence, opinion is indistinguishable from prejudice.
&lt;p align=right&gt; [http://thebottomline.cpaaustralia.com.au/|RIP Neil Armstrong]&lt;/p&gt;&lt;/div&gt;
&lt;/font&gt;

&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1008652</field>
<field name="parent_node">
1008652</field>
</data>
</node>
