<p>In Unix, at least, &quot;check, then act&quot; is generally considered unwise:<br>
1. Something can go wrong between checking and acting.<br>
2. You might not be checking the right thing(s).  In this case, the fact that the file exists is not useful if you don&#39;t have permission to execute it. You may not be able to determine whether you have the appropriate permissions without fairly deep manipulation of ACLs.<br>

3. Even if the OS has the info at hand, making the system call(s) necessary to get it is not free. Various non-free things happen every time control passes between user-space and kernel-space.</p>
<div class="gmail_quote">On Aug 13, 2012 4:17 AM, &quot;Andrew Cowie&quot; &lt;<a href="mailto:andrew@operationaldynamics.com">andrew@operationaldynamics.com</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Sun, 2012-08-12 at 23:18 -0700, Evan Laforge wrote:<br>
&gt; Yes, I ran into the same thing a while back.  The problem is that the<br>
&gt; subprocess has already been forked off before it runs exec() and finds<br>
&gt; out the file doesn&#39;t exist.<br>
<br>
Given how astonishingly common it is to pass an invalid executable name<br>
and/or path, wouldn&#39;t it be worth doing a quick probe to see if the file<br>
exists before createProcess actually forks?<br>
<br>
[It&#39;s not like the effort the OS is going to do for the stat is going to<br>
be thrown away; whether that call pulls it up off of disk or the one<br>
after the fork that exec will do doesn&#39;t matter]<br>
<br>
AfC<br>
Sydney<br>
<br>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div>