[Haskell-cafe] createProcess running non-existent programs
david.feuer at gmail.com
Mon Aug 13 11:23:05 CEST 2012
In Unix, at least, "check, then act" is generally considered unwise:
1. Something can go wrong between checking and acting.
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'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.
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.
On Aug 13, 2012 4:17 AM, "Andrew Cowie" <andrew at operationaldynamics.com>
> On Sun, 2012-08-12 at 23:18 -0700, Evan Laforge wrote:
> > Yes, I ran into the same thing a while back. The problem is that the
> > subprocess has already been forked off before it runs exec() and finds
> > out the file doesn't exist.
> Given how astonishingly common it is to pass an invalid executable name
> and/or path, wouldn't it be worth doing a quick probe to see if the file
> exists before createProcess actually forks?
> [It's not like the effort the OS is going to do for the stat is going to
> be thrown away; whether that call pulls it up off of disk or the one
> after the fork that exec will do doesn't matter]
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe